Ejemplo n.º 1
0
        static void SetPreprocessorRpSymbols(RenderPipeline rpTarget)
        {
            Debug.Log($"Setting preprocessor symbols for {rpTarget.PrettyName()}");
            List <string> symbols = GetCurrentKeywords();

            bool changed = false;

            void CheckRpSymbol(RenderPipeline rp)
            {
                bool   on     = rp == rpTarget;
                string ppName = rp.PreprocessorDefineName();

                if (on && symbols.Contains(ppName) == false)
                {
                    symbols.Add(ppName);
                    changed = true;
                }
                else if (on == false && symbols.Remove(ppName))
                {
                    changed = true;
                }
            }

            CheckRpSymbol(RenderPipeline.URP);
            CheckRpSymbol(RenderPipeline.HDRP);

            if (changed && ShapesIO.TryMakeAssetsEditable(ShapesIO.projectSettingsPath))
            {
                //Debug.Log( $"Shapes updated your project scripting define symbols since you seem to be using {rpTarget.PrettyName()}, I hope that's okay~" );
                SetCurrentKeywords(symbols);
            }
        }
Ejemplo n.º 2
0
 internal static void ForceSetRP(RenderPipeline targetRP)
 {
     Debug.Log($"Shapes is recompiling for {targetRP.PrettyName()}...");
     ForceSetRpFirstPass(targetRP);
     EditorApplication.delayCall += () => {
         ForceSetRpSecondPass(targetRP);
         Debug.Log($"Shapes is done recompiling");
     };
 }
Ejemplo n.º 3
0
        static void AutoCheckRenderPipeline()
        {
            RenderPipeline    rpInUnity = UnityInfo.GetCurrentRenderPipelineInUse();
            ShapesImportState inst      = Instance;

            if (inst == null)
            {
                Debug.LogWarning("Failed to get import state - Shapes will retry on the next script recompile");
                return;                 // I guess some weird import order shenan happened? :c
            }

            // make sure we have a valid RP state
            bool           valid     = true;
            string         error     = "";
            RenderPipeline rpShaders = Instance.currentShaderRP;

            if (rpInUnity != rpShaders)
            {
                valid  = false;
                error += $" • Shape's shaders are compiled for {rpShaders.PrettyName()}\n";
            }

            if (TryGetPreprocessorRP(out RenderPipeline rpPreproc))
            {
                if (rpInUnity != rpPreproc)
                {
                    valid  = false;
                    error += $" • The project keywords are set up for {rpPreproc.PrettyName()}\n";
                }
            }
            else
            {
                valid  = false;
                error += $" • The project keywords are incorrectly set to both HDRP and URP\n";
            }

            if (valid == false)
            {
                string desc = $"Shapes detected a mismatch in render pipeline state.\n" +
                              $"It looks like you are using {rpInUnity.PrettyName()}, but:\n{error}" +
                              $"Would you like to recompile Shapes for your render pipeline?\n(Shapes may not work if you don't)\n\n" +
                              $"Note: You disable this auto-checker in the Shapes settings";

                if (EditorUtility.DisplayDialog("Render pipeline mismatch", desc, $"Recompile for {rpInUnity.PrettyName()}", "cancel"))
                {
                    ForceSetRP(rpInUnity);
                }
            }
        }
Ejemplo n.º 4
0
        static void EnsurePreprocessorsAreDefined(RenderPipeline rpTarget)
        {
            BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
            List <string>    symbols          = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup).Split(';').ToList();

            bool changed = false;

            void CheckRpSymbol(RenderPipeline rp)
            {
                bool   on     = rp == rpTarget;
                string ppName = rp.PreprocessorDefineName();

                if (on && symbols.Contains(ppName) == false)
                {
                    symbols.Add(ppName);
                    changed = true;
                }
                else if (on == false && symbols.Remove(ppName))
                {
                    changed = true;
                }
            }

            CheckRpSymbol(RenderPipeline.URP);
            CheckRpSymbol(RenderPipeline.HDRP);

            if (changed)
            {
                Debug.Log($"Shapes updated your project scripting define symbols since you seem to be using {rpTarget.PrettyName()}, I hope that's okay~");
                PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Join(";", symbols));
            }
        }