鼠标控制旋转
float speed = 100.0f;
float x;
float y;
void Update () {
if(Input.GetMouseButton(0)){//鼠标按着左键移动
y = Input.GetAxis("Mouse X") * Time.deltaTime * speed;
x = Input.GetAxis("Mouse Y") * Time.deltaTime * speed;
}else
{ x = y = 0 ; }
//旋转角度(增加)
transform.Rotate(new Vector3(x,y,0));
触摸控制旋转
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)//状态是move
{
x = Input.GetTouch(0).position.x*Time.deltaTime*Rotatespeed;
y = Input.GetTouch(0).position.y * Time.deltaTime * Rotatespeed;
transform.Rotate(new Vector3(x, y, 0));
}