脚本MouseLook(在主相机上):
using UnityEngine;
using System.Collections;
public class Mouselook : MonoBehaviour {
public enum RotationAxes{
MouseXAndY = 0,
MouseX =1,
MouseY =2
}
public RotationAxes axes = RotationAxes.MouseXAndY;
public float sensitivityHor = 9f;
public float sensitivityVert = 9f;
public float minmumVert = -45f;
public float maxmumVert = 45f;
private float _rotationX = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (axes == RotationAxes.MouseX)
{
transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityHor, 0);
}
else if (axes == RotationAxes.MouseY)
{
_rotationX = _rotationX - Input.GetAxis("Mouse Y") * sensitivityVert;
_rotat