Exemple #1
0
        private static bool CheckShouldFixFeature()
        {
            var activeAssets = PipelineAssetUtility.ActiveAssets;

            foreach (var asset in activeAssets)
            {
                if (!PipelineAssetUtility.IsURPOrLWRP(asset))
                {
                    continue;
                }

                if (!PipelineAssetUtility.IsAssetContainsSRPOutlineFeature(asset))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
 private static void SelectAssetToAddFeature(RenderPipelineAsset asset)
 {
     Selection.activeObject = PipelineAssetUtility.GetRenderer(asset);
 }
Exemple #3
0
        public void OnGUI()
        {
            if (logoImage == null)
            {
                logoImage = Resources.Load <Texture2D>("Easy performant outline/EP Outline logo");
            }

            var height = 180;

            GUILayout.Space(height);

            var imagePosition = new Rect(Vector2.zero, new Vector2(position.width, height));

            GUI.DrawTexture(imagePosition, logoImage, ScaleMode.ScaleAndCrop, true);

            GUILayout.Space(10);

            if (EditorApplication.isPlaying)
            {
                EditorGUILayout.HelpBox("Please stop running the app to start setup process", MessageType.Info);

                if (GUILayout.Button("Stop"))
                {
                    EditorApplication.isPlaying = false;
                }

                return;
            }

            if (EditorApplication.isCompiling)
            {
                EditorGUILayout.HelpBox(new GUIContent("Compiling... please wait."));
                return;
            }

            EditorGUILayout.HelpBox("Warning!\n Don't add integrations that is not available in your project. This will lead to compilation errors", MessageType.Warning);

            EditorGUILayout.LabelField("Integrations");

            EditorGUI.indentLevel = 1;

            var shouldAddDotween = EditorGUILayout.Toggle(new GUIContent("DOTween support"), CheckHasEPODotween());

            if (shouldAddDotween)
            {
                AddDOTweenDefinition();
            }
            else
            {
                RemoveDOTweenDefinition();
            }

            EditorGUILayout.Space();

            EditorGUI.indentLevel = 0;

            EditorGUILayout.LabelField("URP Setup");

            EditorGUI.indentLevel = 1;

            if (addRequest != null && !addRequest.IsCompleted)
            {
                EditorGUILayout.HelpBox(new GUIContent("Adding package..."));
                return;
            }

            var packageName =
#if UNITY_2019_3_OR_NEWER
                "com.unity.render-pipelines.universal";
#else
                "com.unity.render-pipelines.lightweight";
#endif

            if (!pipelineWasFound)
            {
                EditorGUILayout.HelpBox(new GUIContent("There are no package added. Chick 'Add' to add the pipeline package."));

                if (GUILayout.Button("Add"))
                {
                    addRequest = Client.Add(packageName);
                }

                return;
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("Pipeline asset has been found in packages"));
            }

            if (!CheckHasSRPOutlineDefinition())
            {
                EditorGUILayout.HelpBox(new GUIContent("There is no URP_OUTLINE feature added. Click 'Add' to fix it."));
                if (GUILayout.Button("Add"))
                {
                    AddSRPDefinition();
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("URP_OUTLINE definition is added"));
            }

#if URP_OUTLINE
            if (!CheckHasActiveRenderers())
            {
                EditorGUILayout.HelpBox(new GUIContent("There are not renderer asset seted up. Create one?"));

                if (GUILayout.Button("Create"))
                {
                    var path = EditorUtility.SaveFilePanelInProject("Asset location", "Rendering asset", "asset", "Select the folder to save rendering asset");
                    if (string.IsNullOrEmpty(path))
                    {
                        return;
                    }

                    var pathNoExt = Path.ChangeExtension(path, string.Empty);
                    pathNoExt = pathNoExt.Substring(0, pathNoExt.Length - 1);

                    var rendererAsset = PipelineAssetUtility.CreateRenderData();
                    var asset         = PipelineAssetUtility.CreateAsset(rendererAsset);
                    GraphicsSettings.renderPipelineAsset = asset;
                    AssetDatabase.CreateAsset(rendererAsset, pathNoExt + " renderer.asset");
                    AssetDatabase.CreateAsset(asset, path);
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("At least one renderer asset is set up"));
            }

            if (CheckShouldFixFeature())
            {
                var assets = PipelineAssetUtility.ActiveAssets;
                foreach (var asset in assets)
                {
                    if (PipelineAssetUtility.IsAssetContainsSRPOutlineFeature(asset))
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal();

                    var text = string.Format("There is no outline feature added to the pipeline asset called '{0}'. Click select to find asset that is missing outline features", asset.name);
                    EditorGUILayout.HelpBox(new GUIContent(text));
                    if (GUILayout.Button("Select"))
                    {
                        SelectAssetToAddFeature(asset);
                    }

                    GUILayout.EndHorizontal();
                }

                return;
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("Feature is added for all renderers in use"));
            }
#endif
        }
Exemple #4
0
        private void DrawURPSetup()
        {
            if (addRequest != null && !addRequest.IsCompleted)
            {
                EditorGUILayout.HelpBox(new GUIContent("Adding package..."));
                return;
            }

            var packageName =
#if UNITY_2019_3_OR_NEWER
                "com.unity.render-pipelines.universal";
#else
                "com.unity.render-pipelines.lightweight";
#endif

            if (!UPRWasFound)
            {
                EditorGUILayout.HelpBox(new GUIContent("There are no package added. Chick 'Add' to add the pipeline package."));

                if (GUILayout.Button("Add"))
                {
                    addRequest = Client.Add(packageName);
                }

                return;
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("Pipeline asset has been found in packages"));
            }

            if (!CheckHasURPOutlineDefinition())
            {
                EditorGUILayout.HelpBox(new GUIContent("There is no URP_OUTLINE feature added. Click 'Add' to fix it."));
                if (GUILayout.Button("Add"))
                {
                    AddURPDefinition();
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("URP_OUTLINE definition is added"));
            }

#if URP_OUTLINE
            if (!CheckHasActiveRenderers())
            {
                EditorGUILayout.HelpBox(new GUIContent("There are not renderer asset set up. Create one?"));

                if (GUILayout.Button("Create"))
                {
                    var path = EditorUtility.SaveFilePanelInProject("Asset location", "Rendering asset", "asset", "Select the folder to save rendering asset");
                    if (string.IsNullOrEmpty(path))
                    {
                        GUILayout.EndScrollView();
                        return;
                    }

                    var pathNoExt = Path.ChangeExtension(path, string.Empty);
                    pathNoExt = pathNoExt.Substring(0, pathNoExt.Length - 1);

                    var rendererAsset = PipelineAssetUtility.CreateRenderData();
                    var asset         = PipelineAssetUtility.CreateAsset(rendererAsset);
                    GraphicsSettings.renderPipelineAsset = asset;
                    AssetDatabase.CreateAsset(rendererAsset, pathNoExt + " renderer.asset");
                    AssetDatabase.CreateAsset(asset, path);
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("At least one renderer asset is set up"));
            }

            if (CheckShouldFixFeature())
            {
                var assets = PipelineAssetUtility.ActiveAssets;
                foreach (var asset in assets)
                {
                    if (PipelineAssetUtility.IsAssetContainsSRPOutlineFeature(asset))
                    {
                        continue;
                    }

                    EditorGUI.indentLevel = 0;

                    var text = string.Format("There is no outline feature added to the pipeline asset called '{0}'. Please add the feature:", asset.name);
                    EditorGUILayout.HelpBox(new GUIContent(text));

                    Editor previous = null;
                    Editor.CreateCachedEditor(PipelineAssetUtility.GetRenderer(asset), null, ref previous);

                    previous.OnInspectorGUI();
                }

                for (var index = 0; index < 10; index++)
                {
                    EditorGUILayout.Space();
                }

                return;
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("Feature is added for all renderers in use"));
            }
#endif
        }
Exemple #5
0
        private void DrawHDRPSetup()
        {
            if (addRequest != null && !addRequest.IsCompleted)
            {
                EditorGUILayout.HelpBox(new GUIContent("Adding package..."));
                return;
            }

            var packageName = "com.unity.render-pipelines.high-definition";

            if (!HDRPWasFound)
            {
                EditorGUILayout.HelpBox(new GUIContent("There are no package added. Chick 'Add' to add the pipeline package."));

                if (GUILayout.Button("Add"))
                {
                    addRequest = Client.Add(packageName);
                }

                return;
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("Pipeline asset has been found in packages"));
            }

            if (!CheckHasHDRPOutlineDefinition())
            {
                EditorGUILayout.HelpBox(new GUIContent("There is no HDRP_OUTLINE feature added. Click 'Add' to fix it."));
                if (GUILayout.Button("Add"))
                {
                    AddHDRPDefinition();
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("HDRP_OUTLINE definition is added"));
            }

#if HDRP_OUTLINE
            if (!CheckHasActiveRenderers())
            {
                EditorGUILayout.HelpBox(new GUIContent("There are not renderer asset set up. Create one?"));

                if (GUILayout.Button("Create"))
                {
                    var path = EditorUtility.SaveFilePanelInProject("Asset location", "Rendering asset", "asset", "Select the folder to save rendering asset");
                    if (string.IsNullOrEmpty(path))
                    {
                        GUILayout.EndScrollView();
                        return;
                    }

                    var pathNoExt = Path.ChangeExtension(path, string.Empty);
                    pathNoExt = pathNoExt.Substring(0, pathNoExt.Length - 1);

                    var asset = PipelineAssetUtility.CreateHDRPAsset();
                    GraphicsSettings.renderPipelineAsset = asset;
                    AssetDatabase.CreateAsset(asset, path);
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("At least one renderer asset is set up"));
            }

            var volume = FindObjectOfType <CustomPassVolume>();
            if (volume == null)
            {
                EditorGUILayout.HelpBox(new GUIContent("There is no custom pass volume in the scene. Click Add to fix it."));

                if (GUILayout.Button("Add"))
                {
                    var go = new GameObject("Custom volume");
                    go.AddComponent <CustomPassVolume>();

                    EditorUtility.SetDirty(go);
                }
            }
            else
            {
                EditorGUILayout.HelpBox(new GUIContent("The scene has custom pass volume."));

                if (volume.customPasses.Find(x => x is OutlineCustomPass) == null)
                {
                    EditorGUILayout.HelpBox(new GUIContent("The volume doesn't have custom pass. Click Add to fix it."));
                    if (GUILayout.Button("Add"))
                    {
                        volume.AddPassOfType(typeof(OutlineCustomPass));

                        EditorUtility.SetDirty(volume);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox(new GUIContent("The custom volume is set up"));
                }
            }
#endif
        }
Exemple #6
0
        public override void OnInspectorGUI()
        {
            var maskProperty = serializedObject.FindProperty("outlineLayerMask");
            var currentMask  = maskProperty.longValue;

            var maskValue = "Mask: none";

            if (currentMask == -1 || currentMask == long.MaxValue)
            {
                maskValue = "Mask: all";
            }
            else if (currentMask != 0)
            {
                maskValue = "Mask: mixed";
            }

            if (GUILayout.Button(maskValue, EditorStyles.layerMaskField))
            {
                var maskMenu = new GenericMenu();

                maskMenu.AddItem(new GUIContent("none"), currentMask == 0, () =>
                {
                    maskProperty.longValue = 0;
                    serializedObject.ApplyModifiedProperties();
                });

                maskMenu.AddItem(new GUIContent("all"), currentMask == -1 || currentMask == long.MaxValue, () =>
                {
                    maskProperty.longValue = -1;
                    serializedObject.ApplyModifiedProperties();
                });

                for (var index = 0; index < sizeof(long) * 8; index++)
                {
                    var capturedIndex = index;

                    if (index >= 20)
                    {
                        var decima       = index / 10;
                        var lowerDecima  = decima * 10;
                        var higherDecima = (decima + 1) * 10;
                        if (higherDecima > 63)
                        {
                            higherDecima = 63;
                        }

                        maskMenu.AddItem(new GUIContent(lowerDecima + "-" + higherDecima + "/" + index), (currentMask & 1 << index) != 0, () =>
                        {
                            maskProperty.longValue = currentMask ^ (1 << capturedIndex);
                            serializedObject.ApplyModifiedProperties();
                        });
                    }
                    else
                    {
                        maskMenu.AddItem(new GUIContent(index.ToString()), (currentMask & 1 << index) != 0, () =>
                        {
                            maskProperty.longValue = currentMask ^ (1 << capturedIndex);
                            serializedObject.ApplyModifiedProperties();
                        });
                    }
                }

                maskMenu.ShowAsContext();
            }

#if (URP_OUTLINE || HDRP_OUTLINE) && UNITY_EDITOR && UNITY_2019_1_OR_NEWER
            var isHDRP = PipelineAssetUtility.IsHDRP(PipelineAssetUtility.CurrentAsset);
#else
            var isHDRP = false;
#endif

            if (isHDRP)
            {
                DrawPropertiesExcluding(serializedObject,
                                        "m_Script",
                                        "outlineLayerMask",
                                        "infoRendererScale",
                                        "primaryRendererScale");
            }
            else
            {
                DrawPropertiesExcluding(serializedObject,
                                        "m_Script",
                                        "outlineLayerMask",
                                        "infoRendererScale");
            }

            if (!isHDRP)
            {
                EditorGUILayout.PropertyField(serializedObject.FindProperty("infoRendererScale"));
            }

            serializedObject.ApplyModifiedProperties();
        }