Ejemplo n.º 1
0
    void LateUpdate()
    {
#if UNITY_5 || UNITY_2017 || UNITY_2018 || UNITY_2019
#else
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            Interactive       = !Interactive;
            Screen.lockCursor = Interactive;
        }
#endif
        if (cameras.Length == 0)
        {
            return;
        }

        if (Interactive)
        {
            MouseDelta.x = Input.GetAxis("Mouse X");
            MouseDelta.y = Input.GetAxis("Mouse Y");
            MouseDelta.z = Input.GetAxis("Mouse ScrollWheel");
        }
        else
        {
            MouseDelta = Vector3.zero;
        }

        if (currentCamera)
        {
            currentCamera.CameraUpdate(this);
            currentCamera.UpdateFOV();

            cameraCurrentFOV = currentCamera.GetFOV();
            cameraCurrentPos = currentCamera.GetCamPos();
            cameraCurrentRot = currentCamera.GetCamRot();

            Vector3 pos = cameraCurrentPos;
            Vector3 rot = cameraCurrentRot;

            if (pos.y < 0.1f)
            {
                pos.y = 0.1f;
            }

            if (Application.isPlaying)
            {
                transform.position      = pos;
                transform.eulerAngles   = rot;
                Camera.main.fieldOfView = cameraCurrentFOV;
            }
        }
    }