static void CheckRenderPipeline()
        {
            RenderPipeline    rpInUnity = UnityInfo.GetCurrentRenderPipelineInUse();
            ShapesImportState inst      = Instance;

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

            RenderPipeline rpShapesShaders = inst.currentShaderRP;

            if (rpInUnity != rpShapesShaders)
            {
                string rpStr = rpInUnity.ToString();
                if (rpInUnity == RenderPipeline.Legacy)
                {
                    rpStr = "the built-in render pipeline";
                }
                string desc = $"Looks like you're using {rpStr}!\nShapes will now regenerate all shaders, it might take a lil while~";
                EditorUtility.DisplayDialog("Shapes", desc, "ok");
                CodegenShaders.GenerateShadersAndMaterials();
            }
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
0
        static void CheckRenderPipeline()
        {
            RenderPipeline    rpInUnity = UnityInfo.GetCurrentRenderPipelineInUse();
            ShapesImportState inst      = Instance;

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

            // set up preprocessor defines, this will also indirectly trigger a second pass of this whole method
            EnsurePreprocessorsAreDefined(rpInUnity);

            // makes sure all shaders are compiled to a specific render pipeline
            RenderPipeline rpShapesShaders = inst.currentShaderRP;

            if (rpInUnity != rpShapesShaders)
            {
                string rpStr = rpInUnity.ToString();
                if (rpInUnity == RenderPipeline.Legacy)
                {
                    rpStr = "the built-in render pipeline";
                }
                string desc = $"Looks like you're using {rpStr}!\nShapes will now regenerate all shaders, it might take a lil while~";
                EditorUtility.DisplayDialog("Shapes", desc, "ok");
                CodegenShaders.GenerateShadersAndMaterials();
            }

            // second pass check - make sure URP forward renderer has the custom Shapes pass in it
                        #if SHAPES_URP
            EnsureShapesPassExistsInTheUrpRenderer();
                        #endif

            // also on second pass
            MakeSureSampleMaterialsAreValid();
        }