Пример #1
0
        static void ApplyPostFX(CinemachineBrain brain)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.ApplyPostFX");
            PostProcessLayer ppLayer = brain.GetComponent <PostProcessLayer>();

            if (ppLayer == null || !ppLayer.enabled || ppLayer.volumeLayer == 0)
            {
                return;
            }

            CameraState state                = brain.CurrentCameraState;
            int         numBlendables        = state.NumCustomBlendables;
            List <PostProcessVolume> volumes = GetDynamicBrainVolumes(brain, ppLayer, numBlendables);

            for (int i = 0; i < volumes.Count; ++i)
            {
                volumes[i].weight        = 0;
                volumes[i].sharedProfile = null;
                volumes[i].profile       = null;
            }
            for (int i = 0; i < numBlendables; ++i)
            {
                var b = state.GetCustomBlendable(i);
                CinemachinePostProcessing src = b.m_Custom as CinemachinePostProcessing;
                if (!(src == null)) // in case it was deleted
                {
                    PostProcessVolume v = volumes[i];
                    v.sharedProfile = src.Profile;
                    v.isGlobal      = true;
                    v.priority      = float.MaxValue - 1;
                    v.weight        = b.m_Weight;
                }
            }
            //UnityEngine.Profiling.Profiler.EndSample();
        }
        private static void ApplyPostFX(CinemachineBrain brain)
        {
            PostProcessLayer component = brain.GetComponent <PostProcessLayer>();

            if (component == null || !component.enabled || component.volumeLayer == 0)
            {
                return;
            }
            CameraState currentCameraState  = brain.CurrentCameraState;
            int         numCustomBlendables = currentCameraState.NumCustomBlendables;
            List <PostProcessVolume> dynamicBrainVolumes = CinemachinePostProcessing.GetDynamicBrainVolumes(brain, component, numCustomBlendables);

            for (int i = 0; i < dynamicBrainVolumes.Count; i++)
            {
                dynamicBrainVolumes[i].weight        = 0f;
                dynamicBrainVolumes[i].sharedProfile = null;
                dynamicBrainVolumes[i].profile       = null;
            }
            for (int j = 0; j < numCustomBlendables; j++)
            {
                CameraState.CustomBlendable customBlendable           = currentCameraState.GetCustomBlendable(j);
                CinemachinePostProcessing   cinemachinePostProcessing = customBlendable.m_Custom as CinemachinePostProcessing;
                if (!(cinemachinePostProcessing == null))
                {
                    PostProcessVolume postProcessVolume = dynamicBrainVolumes[j];
                    postProcessVolume.sharedProfile = cinemachinePostProcessing.Profile;
                    postProcessVolume.isGlobal      = true;
                    postProcessVolume.priority      = float.MaxValue;
                    postProcessVolume.weight        = customBlendable.m_Weight;
                }
            }
        }
Пример #3
0
        private static void OnCameraCut(CinemachineBrain brain)
        {
            PostProcessLayer ppLayer = CinemachinePostProcessing.GetPPLayer(brain);

            if (!Object.op_Inequality((Object)ppLayer, (Object)null))
            {
                return;
            }
            ppLayer.ResetHistory();
        }
        static void ApplyPostFX(CinemachineBrain brain)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.ApplyPostFX");
            PostProcessLayer ppLayer = brain.PostProcessingComponent as PostProcessLayer;

            if (ppLayer == null || !ppLayer.enabled || ppLayer.volumeLayer == 0)
            {
                return;
            }

            CameraState state                = brain.CurrentCameraState;
            int         numBlendables        = state.NumCustomBlendables;
            List <PostProcessVolume> volumes = GetDynamicBrainVolumes(brain, ppLayer, numBlendables);

            for (int i = 0; i < volumes.Count; ++i)
            {
                volumes[i].weight        = 0;
                volumes[i].sharedProfile = null;
                volumes[i].profile       = null;
            }
            PostProcessVolume firstVolume = null;
            int numPPblendables           = 0;

            for (int i = 0; i < numBlendables; ++i)
            {
                var b = state.GetCustomBlendable(i);
                CinemachinePostProcessing src = b.m_Custom as CinemachinePostProcessing;
                if (!(src == null)) // in case it was deleted
                {
                    PostProcessVolume v = volumes[i];
                    if (firstVolume == null)
                    {
                        firstVolume = v;
                    }
                    v.sharedProfile = src.Profile;
                    v.isGlobal      = true;
                    v.priority      = float.MaxValue - (numBlendables - i) - 1;
                    v.weight        = b.m_Weight;
                    ++numPPblendables;
                }
#if true // set this to true to force first weight to 1
                // If more than one volume, then set the frst one's weight to 1
                if (numPPblendables > 1)
                {
                    firstVolume.weight = 1;
                }
#endif
            }
            //UnityEngine.Profiling.Profiler.EndSample();
        }
Пример #5
0
        static void StaticPostFXHandler(CinemachineBrain brain)
        {
            PostProcessLayer postFX = brain.PostProcessingComponent as PostProcessLayer;

            if (postFX == null)
            {
                brain.PostProcessingComponent = brain.GetComponent <PostProcessLayer>();
                postFX = brain.PostProcessingComponent as PostProcessLayer;
                if (postFX != null)
                {
                    brain.m_CameraCutEvent.AddListener(CinemachinePostProcessing.OnCameraCut);
                }
            }
            if (postFX != null)
            {
                CinemachinePostProcessing.ApplyPostFX(brain);
            }
        }
Пример #6
0
        private static void StaticPostFXHandler(CinemachineBrain brain)
        {
            PostProcessLayer x = brain.PostProcessingComponent as PostProcessLayer;

            if (x == null)
            {
                brain.PostProcessingComponent = brain.GetComponent <PostProcessLayer>();
                x = (brain.PostProcessingComponent as PostProcessLayer);
                if (x != null)
                {
                    brain.m_CameraCutEvent.AddListener(new UnityAction <CinemachineBrain>(CinemachinePostProcessing.OnCameraCut));
                }
            }
            if (x != null)
            {
                CinemachinePostProcessing.ApplyPostFX(brain);
            }
        }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == playerTag)
     {
         postProcessingExtension = virtualCamera.gameObject.GetComponent <Cinemachine.PostFX.CinemachinePostProcessing>();
         if (postProcessingExtension == null)
         {
             postProcessingExtension = virtualCamera.gameObject.AddComponent <Cinemachine.PostFX.CinemachinePostProcessing>();
         }
         postProcessingExtension.m_Profile = postProcessProfile;
         vignette = postProcessProfile.GetSetting <Vignette>();
         if (StopInterpolation != null)
         {
             StopInterpolation.Invoke();
         }
         shouldInterpVignette = true;
     }
 }
Пример #8
0
        private static void ApplyPostFX(CinemachineBrain brain)
        {
            PostProcessLayer ppLayer = CinemachinePostProcessing.GetPPLayer(brain);

            if (Object.op_Equality((Object)ppLayer, (Object)null) || !((Behaviour)ppLayer).get_enabled() || LayerMask.op_Implicit((LayerMask)ppLayer.volumeLayer) == 0)
            {
                return;
            }
            CameraState currentCameraState = brain.get_CurrentCameraState();
            int         customBlendables   = ((CameraState) ref currentCameraState).get_NumCustomBlendables();
            List <PostProcessVolume> dynamicBrainVolumes = CinemachinePostProcessing.GetDynamicBrainVolumes(brain, ppLayer, customBlendables);

            for (int index = 0; index < dynamicBrainVolumes.Count; ++index)
            {
                dynamicBrainVolumes[index].weight        = (__Null)0.0;
                dynamicBrainVolumes[index].sharedProfile = null;
                dynamicBrainVolumes[index].set_profile((PostProcessProfile)null);
            }
            PostProcessVolume postProcessVolume1 = (PostProcessVolume)null;
            int num = 0;

            for (int index = 0; index < customBlendables; ++index)
            {
                CameraState.CustomBlendable customBlendable = ((CameraState) ref currentCameraState).GetCustomBlendable(index);
                CinemachinePostProcessing   custom          = customBlendable.m_Custom as CinemachinePostProcessing;
                if (!Object.op_Equality((Object)custom, (Object)null))
                {
                    PostProcessVolume postProcessVolume2 = dynamicBrainVolumes[index];
                    if (Object.op_Equality((Object)postProcessVolume1, (Object)null))
                    {
                        postProcessVolume1 = postProcessVolume2;
                    }
                    postProcessVolume2.sharedProfile = (__Null)custom.Profile;
                    postProcessVolume2.isGlobal      = (__Null)1;
                    postProcessVolume2.priority      = (__Null)(3.40282346638529E+38 - (double)(customBlendables - index) - 1.0);
                    postProcessVolume2.weight        = customBlendable.m_Weight;
                    ++num;
                }
                if (num > 1)
                {
                    postProcessVolume1.weight = (__Null)1.0;
                }
            }
        }
Пример #9
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 (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
            }