public Transform obj;//旋转物体
public float speed = 2;//速度
private bool _mouseDown = false;//判断是否单击
void Update () {
if (Input.GetMouseButtonDown(0))
Click = true;
else if (Input.GetMouseButtonUp(0))
Click = false;
if (Click)
{
float mouseX = Input.GetAxis("Mouse X");///对应X方向上鼠标的移动
float mouseY = Input.GetAxis("Mouse Y");//对应Y方向上鼠标的移动
obj.Rotate(Vector3.up, -fMouseX * speed, Space.World);
obj.Rotate(Vector3.right, fMouseY * speed, Space.World);
}
}
Unity笔记:按住鼠标旋转物体
最新推荐文章于 2024-07-20 15:03:35 发布