Esempio n. 1
0
        // 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();
        }
Esempio n. 2
0
        static void StaticPostFXHandler(CinemachineBrain brain)
        {
            CinemachinePostFX postFX = brain.PostProcessingComponent as CinemachinePostFX;

            if (postFX == null)
            {
                brain.PostProcessingComponent = brain.GetComponent <CinemachinePostFX>();
                postFX = brain.PostProcessingComponent as CinemachinePostFX;
                if (postFX != null)
                {
                    postFX.ConnectToBrain();
                }
            }
            if (postFX != null)
            {
                postFX.PostFXHandler(brain);
            }
        }
Esempio n. 3
0
            static EditorInitialize()
            {
#if UNITY_POST_PROCESSING_STACK_V2
                // We have PPv2
//                CinemachinePostProcessing.InitializeModule();
#else
                // Check for PostProcessing V1.  Define symbol if we have it.
                if (Cinemachine.Utility.ReflectionHelpers.TypeIsDefined("UnityEngine.PostProcessing.PostProcessingBehaviour"))
                {
                    if (Cinemachine.Editor.ScriptableObjectUtility.AddDefineForAllBuildTargets("UNITY_POST_PROCESSING_STACK_V1"))
                    {
                        string path = Cinemachine.Editor.ScriptableObjectUtility.CinemachineInstallAssetPath + "/PostFX/CinemachinePostFX.cs";
                        UnityEditor.AssetDatabase.ImportAsset(path, UnityEditor.ImportAssetOptions.ForceUpdate);
                    }
                }
    #if UNITY_POST_PROCESSING_STACK_V1
                // We have PPv1
                CinemachinePostFX.InitializeModule();
    #endif
#endif
            }
Esempio n. 4
0
        CinemachinePostFX GetEffectivePostFX(ICinemachineCamera vcam)
        {
            while (vcam != null && vcam.LiveChildOrSelf != vcam)
            {
                vcam = vcam.LiveChildOrSelf;
            }
            CinemachinePostFX postFX = null;

            while (vcam != null && postFX == null)
            {
                CinemachineVirtualCameraBase vcamBase = vcam as CinemachineVirtualCameraBase;
                if (vcamBase != null)
                {
                    postFX = vcamBase.GetComponent <CinemachinePostFX>();
                }
                if (postFX != null && !postFX.enabled)
                {
                    postFX = null;
                }
                vcam = vcam.ParentCamera;
            }
            return(postFX);
        }