using UnityEngine; namespace uNature.Demo { public class UN_CameraFly : MonoBehaviour { public static UN_CameraFly _instance; public static bool canMove = true; [SerializeField] public Camera camera; public float normalspeed = 10f; public float sensitivity = 2f; private float yaw; private float pitch; private long lastCheckedSaveBytesLength; public static UN_CameraFly instance { get { return _instance; } } public float speed { get { return normalspeed * (float)((!Input.GetKey(KeyCode.LeftShift)) ? 1 : 2); } } private void Awake() { _instance = this; } public virtual void Update() { if (canMove) { Vector3 zero = Vector3.zero; zero += base.transform.forward * Input.GetAxis("Vertical") * speed; zero += base.transform.right * Input.GetAxis("Horizontal") * speed; base.transform.position += zero * Time.deltaTime; if (Input.GetMouseButton(1)) { yaw += Input.GetAxisRaw("Mouse X") * sensitivity; yaw %= 360f; pitch += (0f - Input.GetAxisRaw("Mouse Y")) * sensitivity; pitch = Mathf.Clamp(pitch, -85f, 85f); base.transform.eulerAngles = new Vector3(pitch, yaw, 0f); } } } } }