using UnityEngine; public class CameraRotateFollowFinger : MonoBehaviour { bool isRotating = false; public GameObject player; /// <summary> /// 旋转速度 /// </summary> public float speed = 100; void Update () { RotateView(); } void RotateView() { if (Input.GetMouseButtonDown(0)) { isRotating = true; //unity Input内部维护虚拟的鼠标指针,在有触摸的时候才更新,如果抬起来的话,第一帧的偏移量特别大,把第一帧return掉 //return 防止手指抬起之后的第一帧偏移量过大,摄像机会回到默认位置 return; } if (Input.GetMouseButtonUp(0)) { isRotating = false; } if(isRotating) { transform.RotateAround(player. transform.position,Vector3.up,Time.deltaTime* speed * Input.GetAxis("Mouse X")); } } }