public class Test : MonoBehaviour {
float speed = 50;
void Update () {
float x = Input.GetAxis("Mouse X");
float y = Input.GetAxis("Mouse Y");
float z = Input.GetAxis("Mouse ScrollWheel");
if (z < 0)
{
if (Camera.main.fieldOfView < 90)
{
Camera.main.fieldOfView += 2;
}
}
if (z > 0)
{
if (Camera.main.fieldOfView > 30)
{
Camera.main.fieldOfView -= 2;
}
}
if(x!=0 || y != 0)
{
x *= speed * Time.deltaTime;//鼠标横向移动变化值
transform.Rotate(0, x, 0);//摄像机随着鼠标在x轴的变化绕y轴旋转
y *= speed * Time.deltaTime;//鼠标纵向移动变化值
transform.Rotate(-y, 0, 0);//摄像机随着鼠标在y轴的变化绕x轴旋转
}
}
}