csharp 用于连续旋转的Unity 3D C#脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 用于连续旋转的Unity 3D C#脚本相关的知识,希望对你有一定的参考价值。
using UnityEngine;
using System.Collections;
// Continous rotation with some parameters
public class Rotation : MonoBehaviour
{
public enum RotationAxis
{
All,
Y,
X,
Z
}
public RotationAxis axis;
public float speedRot = 0.3f;
void Update ()
{
float rot = Time.deltaTime * speedRot;
//Debug.Log("Axis: "+axis);
switch( axis )
{
default:
case RotationAxis.All:
// Debug.Log("Rotating All");
transform.Rotate( new Vector3( rot, rot, rot ) );
break;
case RotationAxis.X:
//Debug.Log("Rotating X");
transform.Rotate( new Vector3( rot, 0f, 0f ) );
break;
case RotationAxis.Y:
//Debug.Log("Rotating Y");
transform.Rotate( new Vector3( 0f, rot, 0f ) );
break;
case RotationAxis.Z:
//Debug.Log("Rotating Z");
transform.Rotate( new Vector3( 0f, 0f, rot ) );
break;
}
}
}
以上是关于csharp 用于连续旋转的Unity 3D C#脚本的主要内容,如果未能解决你的问题,请参考以下文章