ublic class RotationControl : MonoBehaviour
{
public bool CanRotation = true;
// Start is called before the first frame update
void Start()
{
//隐藏或者显示物体
//transform.gameObject.SetActive(true);
}
// Update is called once per frame
void Update()
{
if (CanRotation)
{
//如果鼠标左键按下
if (Input.GetMouseButton(1))
{
float speed = 2.5f;//旋转跟随速度
float OffsetX = Input.GetAxisRaw("Mouse X");//获取鼠标x轴的偏移量
//Input.GetAxisRaw
transform.Rotate(new Vector3(0, -OffsetX, 0) * speed, Space.World);//旋转物体
}
}
}
}