Skip to content

Instantly share code, notes, and snippets.

@yubaoliu
yubaoliu / right-hand-to-left-hand
Last active January 8, 2020 07:53
Convert right hand coordinate to left hand coordinate
Solution 1:
This is from website, however I don't think it's ritht.
static function MayaRotationToUnity(rotation : Vector3) : Quaternion {
var flippedRotation : Vector3 = Vector3(rotation.x, -rotation.y, -rotation.z); // flip Y and Z axis for right->left handed conversion
// convert XYZ to ZYX
var qx : Quaternion = Quaternion.AngleAxis(flippedRotation.x, Vector3.right);
var qy : Quaternion = Quaternion.AngleAxis(flippedRotation.y, Vector3.up);
var qz : Quaternion = Quaternion.AngleAxis(flippedRotation.z, Vector3.forward);
var qq : Quaternion = qz * qy * qx ; // this is the order
return qq;
@yubaoliu
yubaoliu / Create C and C++ plugins for Unity3D
Created October 17, 2017 07:46
How to use C/C++ plugins (C/C++ lib) in Unity3D
"LowLevelPlugin.h"
#pragma once
#if UNITY_METRO
#define EXPORT_API __declspec(dllexport) __stdcall
#elif UNITY_WIN
#define EXPORT_API __declspec(dllexport)
#else
#define EXPORT_API
#endif
@yubaoliu
yubaoliu / UnityPatcher
Created October 17, 2017 07:37
unity3d pattern not found
Error:
unity3d pattern not found
Solustion:
Refer to: http://www.ceeger.com/forum/read.php?tid=23984
How to patch:
Patcher now self-checks if it has been "Run as administrator". It prompts the user if it has not been.
A license key is now randomly auto-generated at the start, and still allows you to regenerate more [one less click for you].
The patcher just asks for the location of the executable, and no longer asks for which version you want to patch.
It works out the version of the selected *.exe and patches it accordingly.
@yubaoliu
yubaoliu / unity3D_git
Created October 16, 2017 00:40
Unity3D 项目用 git 做版本控制
新建项目后,在 Unity 编辑器里选择 Edit -> Project Settings -> Editor,在 Inspector 里面做以下设置:
Version Control - 设置为 Visible Meta Files,这样 .meta 文件就可以添加到版本控制中。
Asset Serialization - 设置为 Force Text,这样项目中像 prefab 和动画等文件会以纯文本格式保存,在看修改的 diff 时会比较好用。
建立 .gitignore 文件,在这里有一份可以直接拿来用的版本。其目的就是为了排除像Library 和 Temp 这些 Unity 可以本地生成的东西。之后 git init 来创建 git repo 就可以了。
建立 .gitattributes 文件。在 Windows 上默认 git 配置会自动将文本文件中的 \n(LF)转换成 \r\n(CRLF),但是 Unity 保存文本文件的时候总是使用的 \n。
这样有一个问题就是你修改了 .meta 文件以后就算再变回原来的设置,git 里面也会显示其被修改过了。因为 git 认为他是文本所以把里面的换行改成了 \r\n,
但是 Unity 保存资源的时候又写的是 \n,这样 git 又认为它变了。在项目根目录建立 .gitattributes 文件如下: