using UnityEngine; public class RotateObj : MonoBehaviour { public float OffsetX = 0; public float OffsetY = 0; public float speed = 6f;//旋转速度 void Update() { if (Input.GetMouseButton(0)) { OffsetX = Input.GetAxis("Mouse X");//获取鼠标x轴的偏移量 OffsetY = Input.GetAxis("Mouse Y");//获取鼠标y轴的偏移量 transform.Rotate(new Vector3(OffsetY, -OffsetX, 0) * speed, Space.World); } } }
using UnityEngine;public class RotateObj : MonoBehaviour{ public float OffsetX = 0; public float OffsetY = 0; public float speed = 6f;//旋转速度
void Update() { if (Input.GetMouseButton(0)) { OffsetX = Input.GetAxis("Mouse X");//获取鼠标x轴的偏移量 OffsetY = Input.GetAxis("Mouse Y");//获取鼠标y轴的偏移量
transform.Rotate(new Vector3(OffsetY, -OffsetX, 0) * speed, Space.World); } }}
原文地址:https://www.cnblogs.com/Transmuter/p/11074539.html
时间: 2024-11-03 20:49:29