Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 40 additions & 1 deletion com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> { }

/// <summary>
/// Enums Debug State.
/// </summary>
[Serializable, DebugState(typeof(DebugUI.EnumField), typeof(DebugUI.HistoryEnumField))]
public sealed class DebugStateEnum : DebugState<int>, ISerializationCallbackReceiver
{
DebugUI.EnumField m_EnumField;

/// <summary>
/// Set the value of the Debug Item.
/// </summary>
/// <param name="value">Input value.</param>
/// <param name="field">Debug Item field.</param>
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);
}
}

/// <summary>
/// On Before Serialize Callback
/// </summary>
public void OnBeforeSerialize() => UpdateValue();

/// <summary>
/// On After Deserialize Callback
/// </summary>
public void OnAfterDeserialize() => UpdateValue();
}

/// <summary>
/// Integer Debug State.
/// </summary>
[Serializable, DebugState(typeof(DebugUI.IntField), typeof(DebugUI.EnumField), typeof(DebugUI.HistoryEnumField))]
[Serializable, DebugState(typeof(DebugUI.IntField))]
public sealed class DebugStateInt : DebugState<int> { }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public sealed class DebugUIDrawerEnumField : DebugUIDrawer
public override bool OnGUI(DebugUI.Widget widget, DebugState state)
{
var w = Cast<DebugUI.EnumField>(widget);
var s = Cast<DebugStateInt>(state);
var s = Cast<DebugStateEnum>(state);

if (w.indexes == null)
w.InitIndexes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public virtual void End(DebugUI.Widget widget, DebugState state)
/// <param name="value">Input value.</param>
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down