标签:inpu axis color locale frame == vector nim tor
enum RotationAxes { MouseXAndY, MouseX, MouseY }
RotationAxes axes = RotationAxes.MouseXAndY;
//@HideInInspector
float sensitivityX = 15;
//@HideInInspector
float sensitivityY = 15;
//private float minimumX = -360; 原文有此行但并未使用此变量
//private float maximumX = 360; 同上
float minimumY = -80;
float maximumY = 80;
private float rotationY = 0;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
if (axes == RotationAxes.MouseXAndY)
{
float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}
}
标签:inpu axis color locale frame == vector nim tor
原文地址:http://www.cnblogs.com/Study088/p/7892528.html