Quaternion.Euler()的意义是
Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis.
也就是说绕x轴旋转x度,y轴旋转y度,z轴旋转z度
Quaternion作用于Vector3的右乘操作(*)返回一个将向量做旋转操作后的向量,也就是说是将一个向量(欧拉角)旋转到指定的角度
例如:Quaternion.Euler(0, 90, 0) * Vector3(0.0, 0.0, -10.0)表示将向量Vector3(0.0, 0.0, -10.0)做绕y轴90度旋转后的结果,等于Vector3(-10.0, 0.0, 0.0).
可以用来做一个物体围绕着一个点来旋转
问题
c# – Action(arg)和Action.Invoke(arg)之间的区别?
解答
All delegate types have a compiler-generated Invoke method.
所有的委托类型,编译器都会自动生成一个 invoke 方法.
C# allows you to call the delegate itself as a shortcut to calling this method.
用委托类型直接加参数是Invoke(参数)的一个捷径.
其实等价调用 Invoke();
类似:
Action<string> x = Console.WriteLine;
x("2");
x.Invoke("2");
开启layer 2
LayerMask mask = 1<<2;
其中 <<左边的 1表示有[开启],0表示没有该layer[忽略] 。右边的2表示左移2位即是 layer2层的位置。
开启layer 0和layer 2
LayerMask mask = 1 << 0 | 1 << 2;
开启Layer0 并关闭 Layer2
LayerMask mask = 1 << 0 | 0 << 2
开启Layer Default
LaserMask mask=1 << LayserMask.NameToLayer(“Default”);
1、int型变量 n 与“零值”比较的 if 语句就是:
if ( n == 0 )
if ( n != 0 )
如下写法均属不良风格.。
if ( n ) // 会让人误解 n 是布尔变量
if ( !n )
2、请写出 BOOL flag 与“零值”比较的 if 语句。
根据布尔类型的语义,零值为“假”(记为FALSE),任何非零值都是“真”(记为TRUE)。TRUE 的值究竟是什么并没有统一的标准。例如Visual C++ 将TRUE 定义为1,而Visual Basic 则将TRUE 定义为-1。所以我们不可以将布尔变量直接与TRUE、FALSE 或者1、0 进行比较。
标准答案:
if ( flag )
if ( !flag )
如下写法均属不良风格。
if (flag == TRUE)
if (flag == 1 )
if (flag == FALSE)
if (flag == 0)
3、请写出 float x 与“零值”比较的 if 语句。
千万要留意,无论是float 还是double 类型的变量,都有精度限制,都不可以用“==”或“!=”与任何数字比较,应该设法转化成“>=”或“<=”形式。(为什么?文章之后有详细的讨论,可参考)
假设浮点变量的名字为x,应当将
if (x == 0.0) // 隐含错误的比较
转化为
if ((x>=-EPSINON) && (x<=EPSINON))
其中EPSINON 是允许的误差(即精度)。
标准答案示例:
const float EPSINON = 0.00001;
if ((x >= - EPSINON) && (x <= EPSINON)
如下是错误的写法。
if (x == 0.0)
if (x != 0.0)