Esempio n. 1
0
 private static void SelectAssetToAddFeature(RenderPipelineAsset asset)
 {
     Selection.activeObject = PipelineAssetUtility.GetRenderer(asset);
 }
Esempio n. 2
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
        }