Ejemplo n.º 1
0
        private void UpdateVirtualCameras(CinemachineCore.UpdateFilter updateFilter, float deltaTime)
        {
            // We always update all active virtual cameras
            CinemachineCore.Instance.CurrentUpdateFilter = updateFilter;
            Camera camera = OutputCamera;

            CinemachineCore.Instance.UpdateAllActiveVirtualCameras(
                camera == null ? -1 : camera.cullingMask, DefaultWorldUp, deltaTime);

            // Make sure all live cameras get updated, in case some of them are deactivated
            if (SoloCamera != null)
            {
                SoloCamera.UpdateCameraState(DefaultWorldUp, deltaTime);
            }
            mCurrentLiveCameras.UpdateCameraState(DefaultWorldUp, deltaTime);

            // Restore the filter for general use
            updateFilter = CinemachineCore.UpdateFilter.Late;
            if (Application.isPlaying)
            {
                if (m_UpdateMethod == UpdateMethod.SmartUpdate)
                {
                    updateFilter |= CinemachineCore.UpdateFilter.Smart;
                }
                else if (m_UpdateMethod == UpdateMethod.FixedUpdate)
                {
                    updateFilter = CinemachineCore.UpdateFilter.Fixed;
                }
            }
            CinemachineCore.Instance.CurrentUpdateFilter = updateFilter;
        }
Ejemplo n.º 2
0
        private void LateUpdate()
        {
            float deltaTime = GetEffectiveDeltaTime(false);

            UpdateFrame0(deltaTime);
            UpdateCurrentLiveCameras();

            if (m_UpdateMethod == UpdateMethod.FixedUpdate)
            {
                // Special handling for fixed update: cameras that have been enabled
                // since the last physics frame must be updated now
                CinemachineCore.Instance.CurrentUpdateFilter = CinemachineCore.UpdateFilter.Fixed;
                if (SoloCamera != null)
                {
                    SoloCamera.UpdateCameraState(DefaultWorldUp, deltaTime);
                }
                mCurrentLiveCameras.UpdateCameraState(DefaultWorldUp, deltaTime);
            }
            else
            {
                CinemachineCore.UpdateFilter filter = CinemachineCore.UpdateFilter.Late;
                if (m_UpdateMethod == UpdateMethod.SmartUpdate)
                {
                    // Track the targets
                    UpdateTracker.OnUpdate(UpdateTracker.UpdateClock.Late);
                    filter = CinemachineCore.UpdateFilter.SmartLate;
                }
                UpdateVirtualCameras(filter, deltaTime);
            }
            // Choose the active vcam and apply it to the Unity camera
            ProcessActiveCamera(deltaTime);
        }