diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 6a1dc9ee692..e546f69814f 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Fixed XR support in CoreUtils.DrawFullscreen function. - Fixed issue in DynamicResolutionHandler when camera request was turned off at runtime, the ScalableBufferManager would leak state and not unset DRS state (case 1383093). +- Fixed undo in for `DebugUI.EnumFields` on the rendering debugger. (case 1386964) - Fixed `DebugUI.Enum` fields collapsing their parent `DebugUI.Foldout` ## [13.1.2] - 2021-11-05 diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs index 06d417e61c4..dbc0a4e7937 100644 --- a/com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs +++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs @@ -134,10 +134,49 @@ public DebugStateAttribute(params Type[] types) [Serializable, DebugState(typeof(DebugUI.BoolField), typeof(DebugUI.Foldout), typeof(DebugUI.HistoryBoolField))] public sealed class DebugStateBool : DebugState { } + /// + /// Enums Debug State. + /// + [Serializable, DebugState(typeof(DebugUI.EnumField), typeof(DebugUI.HistoryEnumField))] + public sealed class DebugStateEnum : DebugState, ISerializationCallbackReceiver + { + DebugUI.EnumField m_EnumField; + + /// + /// Set the value of the Debug Item. + /// + /// Input value. + /// Debug Item field. + public override void SetValue(object value, DebugUI.IValueField field) + { + m_EnumField = field as DebugUI.EnumField; + this.value = (int)field.ValidateValue(value); + } + + void UpdateValue() + { + if (m_EnumField != null) + { + m_EnumField.SetValue(value); + m_EnumField.setIndex?.Invoke(value); + } + } + + /// + /// On Before Serialize Callback + /// + public void OnBeforeSerialize() => UpdateValue(); + + /// + /// On After Deserialize Callback + /// + public void OnAfterDeserialize() => UpdateValue(); + } + /// /// Integer Debug State. /// - [Serializable, DebugState(typeof(DebugUI.IntField), typeof(DebugUI.EnumField), typeof(DebugUI.HistoryEnumField))] + [Serializable, DebugState(typeof(DebugUI.IntField))] public sealed class DebugStateInt : DebugState { } /// diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs index 50e88748a91..071fed71fd8 100644 --- a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs +++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs @@ -304,7 +304,7 @@ public sealed class DebugUIDrawerEnumField : DebugUIDrawer public override bool OnGUI(DebugUI.Widget widget, DebugState state) { var w = Cast(widget); - var s = Cast(state); + var s = Cast(state); if (w.indexes == null) w.InitIndexes(); diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs index 42bd940dc3d..3ce8b5fa531 100644 --- a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs +++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.cs @@ -81,7 +81,7 @@ public virtual void End(DebugUI.Widget widget, DebugState state) /// Input value. protected void Apply(DebugUI.IValueField widget, DebugState state, object value) { - Undo.RegisterCompleteObjectUndo(state, "Debug Property Change"); + Undo.RegisterCompleteObjectUndo(state, $"Debug Property '{state.queryPath}' Change"); state.SetValue(value, widget); widget.SetValue(value); EditorUtility.SetDirty(state); diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs index 1b1d27dc5f8..d1a0e6a97d5 100644 --- a/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs +++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs @@ -422,7 +422,7 @@ void OnGUI() GUI.Toggle(elementRect, m_Settings.selectedPanel == i, panel.displayName, s_Styles.sectionElement); if (EditorGUI.EndChangeCheck()) { - Undo.RegisterCompleteObjectUndo(m_Settings, "Debug Panel Selection"); + Undo.RegisterCompleteObjectUndo(m_Settings, $"Debug Panel '{panel.displayName}' Selection"); var previousPanel = m_Settings.selectedPanel >= 0 && m_Settings.selectedPanel < panels.Count ? panels[m_Settings.selectedPanel] : null;