将此脚本给相机对象
</pre><pre name="code" class="csharp">using UnityEngine;
using System.Collections;
public class CameraLikeScene : MonoBehaviour {
//方向灵敏度
public float sensitivityX = 10F;
public float sensitivityY = 10F;
//上下最大视角(Y视角)
public float minimumY = -60F;
public float maximumY = 60F;
float rotationY = 0F;
private Vector3 PreMouseMPos;
private Vector3 PreMouseLPos;
private float wheelSpeed = 5.0f;
void Start () {
}
void Update () {
CameraMove();
MouseScrollWheel();
Move();
}
private void MouseScrollWheel() {
//滚轮前进后退
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
gameObject.transform.Translate(new Vector3(0, 0, Input.GetAxis("Mouse ScrollWheel") * Time.deltaTime * 500));
}
}
private void CameraMove() {