本文整理汇总了C#中Vector4.SqrMagnitude方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4.SqrMagnitude方法的具体用法?C# Vector4.SqrMagnitude怎么用?C# Vector4.SqrMagnitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector4
的用法示例。
在下文中一共展示了Vector4.SqrMagnitude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
void Update ()
{
// in VR mode, no mouse/gyro at all!
if (UsingVr() )
return;
bool UseGyro = UseGyroOnMobile;
{
if (UseGyro)
Input.gyro.enabled = true;
UseGyro &= Input.gyro.enabled;
}
if (UseGyro)
{
bool GyroValid = Input.gyro.enabled;
{
// first usage of the attituide is all zeros, ignore this
Vector4 Gyro4 = new Vector4( Input.gyro.attitude.x, Input.gyro.attitude.y, Input.gyro.attitude.z, Input.gyro.attitude.w );
GyroValid &= Gyro4.SqrMagnitude() > 0;
}
if ( GyroValid )
{
// correction stolen from google cardboad SDK
var att = Input.gyro.attitude;
att = new Quaternion(att.x, att.y, -att.z, -att.w);
att = Quaternion.Euler(0, 0, 0) * att;
if ( mInitialGyro == null )
{
mInitialGyro = att;
}
transform.localRotation = Quaternion.Inverse(mInitialGyro.Value) * att;
}
}
else if (axes == RotationAxes.MouseXAndY)
{
// Read the mouse input axis
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationX = ClampAngle (rotationX, minimumX, maximumX);
rotationY = ClampAngle (rotationY, minimumY, maximumY);
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, -Vector3.right);
transform.localRotation = originalRotation * xQuaternion * yQuaternion;
}
else if (axes == RotationAxes.MouseX)
{
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationX = ClampAngle (rotationX, minimumX, maximumX);
Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
transform.localRotation = originalRotation * xQuaternion;
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = ClampAngle (rotationY, minimumY, maximumY);
Quaternion yQuaternion = Quaternion.AngleAxis (-rotationY, Vector3.right);
transform.localRotation = originalRotation * yQuaternion;
}
}