コード例 #1
0
        public void DoGUI(string searchContext)
        {
            // When the asset being serialized has been deleted before its reconstruction
            if (serializedSettings != null && serializedSettings.serializedObject.targetObject == null)
            {
                serializedSettings = null;
                settingsSerialized = null;
            }

            if (serializedSettings == null || settingsSerialized != UniversalRenderPipelineGlobalSettings.instance)
            {
                if (UniversalRenderPipeline.asset != null || UniversalRenderPipelineGlobalSettings.instance != null)
                {
                    settingsSerialized = UniversalRenderPipelineGlobalSettings.Ensure();
                    var serializedObject = new SerializedObject(settingsSerialized);
                    serializedSettings = new SerializedUniversalRenderPipelineGlobalSettings(serializedObject);
                }
            }
            else if (settingsSerialized != null && serializedSettings != null)
            {
                serializedSettings.serializedObject.Update();
            }

            DrawAssetSelection(ref serializedSettings, null);
            DrawWarnings(ref serializedSettings, null);
            if (settingsSerialized != null && serializedSettings != null)
            {
                EditorGUILayout.Space();
                Inspector.Draw(serializedSettings, null);
                serializedSettings.serializedObject?.ApplyModifiedProperties();
            }
        }
コード例 #2
0
 static void DrawLightLayerNames(SerializedUniversalRenderPipelineGlobalSettings serialized, Editor owner)
 {
     using (new EditorGUI.IndentLevelScope())
     {
         using (var changed = new EditorGUI.ChangeCheckScope())
         {
             EditorGUILayout.DelayedTextField(serialized.lightLayerName0, Styles.lightLayerName0);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName1, Styles.lightLayerName1);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName2, Styles.lightLayerName2);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName3, Styles.lightLayerName3);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName4, Styles.lightLayerName4);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName5, Styles.lightLayerName5);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName6, Styles.lightLayerName6);
             EditorGUILayout.DelayedTextField(serialized.lightLayerName7, Styles.lightLayerName7);
             if (changed.changed)
             {
                 serialized.serializedObject?.ApplyModifiedProperties();
                 if (serialized.serializedObject?.targetObject is UniversalRenderPipelineGlobalSettings urpGlobalSettings)
                 {
                     urpGlobalSettings.UpdateRenderingLayerNames();
                 }
             }
         }
     }
 }
コード例 #3
0
        static void DrawLightLayerNames(SerializedUniversalRenderPipelineGlobalSettings serialized, Editor owner)
        {
            var oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = Styles.labelWidth;

            using (new EditorGUI.IndentLevelScope())
            {
                DrawDelayedTextField(Styles.lightLayerName0, serialized.lightLayerName0);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName1, serialized.lightLayerName1);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName2, serialized.lightLayerName2);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName3, serialized.lightLayerName3);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName4, serialized.lightLayerName4);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName5, serialized.lightLayerName5);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName6, serialized.lightLayerName6);
                GUILayout.Space(2);
                DrawDelayedTextField(Styles.lightLayerName7, serialized.lightLayerName7);
                EditorGUILayout.Space();
            }

            EditorGUIUtility.labelWidth = oldWidth;
        }
コード例 #4
0
        void DrawAssetSelection(ref SerializedUniversalRenderPipelineGlobalSettings serialized, Editor owner)
        {
            var oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = Styles.labelWidth;
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginChangeCheck();
                var newAsset = (UniversalRenderPipelineGlobalSettings)EditorGUILayout.ObjectField(settingsSerialized, typeof(UniversalRenderPipelineGlobalSettings), false);
                if (EditorGUI.EndChangeCheck())
                {
                    UniversalRenderPipelineGlobalSettings.UpdateGraphicsSettings(newAsset);
                    if (settingsSerialized != null && !settingsSerialized.Equals(null))
                    {
                        EditorUtility.SetDirty(settingsSerialized);
                    }
                }

                if (GUILayout.Button(EditorGUIUtility.TrTextContent("New", "Create a URP Global Settings asset in the Assets folder."), GUILayout.Width(45), GUILayout.Height(18)))
                {
                    UniversalGlobalSettingsCreator.Create(activateAsset: true);
                }

                bool guiEnabled = GUI.enabled;
                GUI.enabled = guiEnabled && (settingsSerialized != null);
                if (GUILayout.Button(EditorGUIUtility.TrTextContent("Clone", "Clone a URP Global Settings asset in the Assets folder."), GUILayout.Width(45), GUILayout.Height(18)))
                {
                    UniversalGlobalSettingsCreator.Clone(settingsSerialized, activateAsset: true);
                }
                GUI.enabled = guiEnabled;
            }
            EditorGUIUtility.labelWidth = oldWidth;
            EditorGUILayout.Space();
        }
コード例 #5
0
        void DrawAssetSelection(ref SerializedUniversalRenderPipelineGlobalSettings serialized, Editor owner)
        {
            var oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = Styles.labelWidth;
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUI.BeginChangeCheck();
                var newAsset = (UniversalRenderPipelineGlobalSettings)EditorGUILayout.ObjectField(settingsSerialized, typeof(UniversalRenderPipelineGlobalSettings), false);
                if (EditorGUI.EndChangeCheck())
                {
                    UniversalRenderPipelineGlobalSettings.UpdateGraphicsSettings(newAsset);
                    Debug.Assert(newAsset == UniversalRenderPipelineGlobalSettings.instance);
                    if (settingsSerialized != null && !settingsSerialized.Equals(null))
                    {
                        EditorUtility.SetDirty(settingsSerialized);
                    }
                }

                if (GUILayout.Button(Styles.newAssetButtonLabel, GUILayout.Width(45), GUILayout.Height(18)))
                {
                    UniversalGlobalSettingsCreator.Create(useProjectSettingsFolder: true, activateAsset: true);
                }

                bool guiEnabled = GUI.enabled;
                GUI.enabled = guiEnabled && (settingsSerialized != null);
                if (GUILayout.Button(Styles.cloneAssetButtonLabel, GUILayout.Width(45), GUILayout.Height(18)))
                {
                    UniversalGlobalSettingsCreator.Clone(settingsSerialized, activateAsset: true);
                }
                GUI.enabled = guiEnabled;
            }
            EditorGUIUtility.labelWidth = oldWidth;
            EditorGUILayout.Space();
        }
コード例 #6
0
        static void OnContextClickLightLayerNames(Vector2 position, SerializedUniversalRenderPipelineGlobalSettings serialized)
        {
            var menu = new GenericMenu();

            menu.AddItem(CoreEditorStyles.resetButtonLabel, false, () =>
            {
                var globalSettings = (serialized.serializedObject.targetObject as UniversalRenderPipelineGlobalSettings);
                globalSettings.ResetRenderingLayerNames();
            });
            menu.DropDown(new Rect(position, Vector2.zero));
        }
コード例 #7
0
        static void DrawMiscSettings(SerializedUniversalRenderPipelineGlobalSettings serialized, Editor owner)
        {
            var oldWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = Styles.labelWidth;

            using (new EditorGUI.IndentLevelScope())
            {
                EditorGUILayout.PropertyField(serialized.supportRuntimeDebugDisplay, Styles.supportRuntimeDebugDisplayContentLabel);
            }

            EditorGUIUtility.labelWidth = oldWidth;
        }
コード例 #8
0
        void DrawWarnings(ref SerializedUniversalRenderPipelineGlobalSettings serialized, Editor owner)
        {
            bool isURPinUse = UniversalRenderPipeline.asset != null;

            if (isURPinUse && serialized != null)
            {
                return;
            }

            if (isURPinUse)
            {
                EditorGUILayout.HelpBox(Styles.warningGlobalSettingsMissing, MessageType.Warning);
            }
            else
            {
                EditorGUILayout.HelpBox(Styles.warningUrpNotActive, MessageType.Warning);
                if (serialized == null)
                {
                    EditorGUILayout.HelpBox(Styles.infoGlobalSettingsMissing, MessageType.Info);
                }
            }
        }
コード例 #9
0
 void OnEnable()
 {
     m_SerializedGlobalSettings = new SerializedUniversalRenderPipelineGlobalSettings(serializedObject);
 }