aboutsummaryrefslogtreecommitdiff
path: root/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs
blob: 11561977016977e98d22eec3d7bd5263afe89d53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

namespace Cinemachine.PostFX
{
    /// <summary>Integrates Cinemachine with PostProcessing V1 stack.</summary>
    /// Since PostPorcessing V1 does not create a define in Player settings the
    /// way V2 does, we do it ourselves if we detect the presence of PostProcessing V1
    class PostFXAutoImport
    {
        [UnityEditor.InitializeOnLoad]
        class EditorInitialize 
        {
            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
            } 
        }
    }
}