Unity 模仿scene视图相机视角移动
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Cam : MonoBehaviour { void Start() { } void Update() { if (Input.GetMouseButton(1)) { float x = Input.GetAxis("Mouse X"); float y = Input.GetAxis("Mouse Y"); transform.Rotate(new Vector3(-y, x)*3); Vector3 v = transform.localEulerAngles; transform.localEulerAngles = new Vector3(v.x,v.y,0); } if (Input.GetMouseButton(0)) { float x = Input.GetAxis("Mouse X"); float y = Input.GetAxis("Mouse Y"); transform.Translate(new Vector3(-x, -y)); } transform.Translate(Vector3.forward*Input.GetAxis("Mouse ScrollWheel")*3); } }