// CinemachineBrain callback used when this behaviour is on the Unity Camera internal void PostFXHandler(CinemachineBrain brain) { //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostFX.PostFXHandler"); ICinemachineCamera vcam = brain.ActiveVirtualCamera; if (enabled && mBrain != null && mPostProcessingBehaviour != null) { // Look for the vcam's PostFX behaviour CinemachinePostFX postFX = GetEffectivePostFX(vcam); if (postFX == null) { postFX = this; // vcam does not define a profile - apply the default } if (postFX.m_Profile != null) { // Adjust the focus distance CameraState state = brain.CurrentCameraState; UnityEngine.PostProcessing.DepthOfFieldModel.Settings dof = postFX.m_Profile.depthOfField.settings; if (postFX.m_FocusTracksTarget && state.HasLookAt) { dof.focusDistance = (state.FinalPosition - state.ReferenceLookAt).magnitude + postFX.m_FocusOffset; } postFX.m_Profile.depthOfField.settings = dof; } // Apply the profile if (mPostProcessingBehaviour.profile != postFX.m_Profile) { mPostProcessingBehaviour.profile = postFX.m_Profile; mPostProcessingBehaviour.ResetTemporalEffects(); } } //UnityEngine.Profiling.Profiler.EndSample(); }