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(); } }
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(); }
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(); }
public void Undo_UPActive_UnregisterGlobalSettings() { EnsureUniversalRPIsActivePipeline(); Undo.IncrementCurrentGroup(); UniversalRenderPipelineGlobalSettings.UpdateGraphicsSettings(null); Assert.IsNull(UniversalRenderPipelineGlobalSettings.instance); Undo.PerformUndo(); Assert.AreEqual(initialGlobalSettings, UniversalRenderPipelineGlobalSettings.instance); }
public void Undo_URPActive_ChangeGlobalSettings() { EnsureUniversalRPIsActivePipeline(); Undo.IncrementCurrentGroup(); UniversalRenderPipelineGlobalSettings.UpdateGraphicsSettings(otherGlobalSettings); Assert.AreEqual(otherGlobalSettings, UniversalRenderPipelineGlobalSettings.instance); Undo.PerformUndo(); Assert.AreEqual(initialGlobalSettings, UniversalRenderPipelineGlobalSettings.instance); }
public void URPFrameRendered_EnsureGlobalSettingsIfNullAssigned() { EnsureUniversalRPIsActivePipeline(); UniversalRenderPipelineGlobalSettings.UpdateGraphicsSettings(null); Assert.IsNull(UniversalRenderPipelineGlobalSettings.instance); Camera.main.Render(); Assert.IsNotNull(UniversalRenderPipelineGlobalSettings.instance); }
void ShowMessageWithFixButton(string helpBoxLabel, MessageType type) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.HelpBox(helpBoxLabel, type); if (GUILayout.Button(Styles.fixAssetButtonLabel, GUILayout.Width(45))) { UniversalRenderPipelineGlobalSettings.Ensure(); } } }
void EnsureUniversalRPIsActivePipeline() { Camera.main.Render(); // Skip test if project is not configured to be SRP project if (RenderPipelineManager.currentPipeline == null) { Assert.Ignore("Test project has no SRP configured, skipping test"); } initialGlobalSettings = UniversalRenderPipelineGlobalSettings.instance; Assert.IsInstanceOf <UniversalRenderPipeline>(RenderPipelineManager.currentPipeline); Assert.IsNotNull(initialGlobalSettings); }
public void SetUp() { UnityEditor.SceneManagement.EditorSceneManager.NewScene(UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects); otherGlobalSettings = ScriptableObject.CreateInstance <UniversalRenderPipelineGlobalSettings>(); }