forked from Unity-Technologies/Graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RPW][HDRP]Multiple fixes on the Rendering Debugger
This PR aims to solve multiple issues with the Rendering Debugger and it's implementation on HDRP. - [[HDRP] Entering Playmode with any Rendering Debugger mode on resets all debug view](https://fogbugz.unity3d.com/f/cases/1401599/) Partially solving this issue, as the current limitations of the framework do not allow how the HDRP is using it. There is a splitted enum across multiple properties that when it is being set, multiple fields are reset or changed. For those to work properly when entering playmode, the enum must be splitted, and as talked with @julien this will be handled by HDRP team. - [[HDRP] Undo action name quickly changes after Rendering Debugger UI is rebuilt](https://fogbugz.unity3d.com/f/cases/1412467/) - [[HDRP] Some Rendering Debug actions are named as HDR: true in undo stack](https://fogbugz.unity3d.com/f/cases/1412465/) The GetReset Method only destroys the IDebugData, but doesnt call the RegisterDebug UI from HDRP, as the new system is not reliying on the recreation of the UI to hide( not add) or show ( add) widgets, this is working out of the box correctly. - [[HDRP] Reset button in Rendering Debugger doesn't update widget visibility](https://fogbugz.unity3d.com/f/cases/1411399/) The main issue with this fogbugz was that all the implementation on the Rendering Debugger on HDRP is registering to the event `onValueChanged` as when it was implemented the callback `isHiddenCallback `did not exist. - Drawers code for editor has been improved and shared.
- Loading branch information
1 parent
252d5a6
commit cdaeaa8
Showing
10 changed files
with
701 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
551 changes: 215 additions & 336 deletions
551
Packages/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging/UndoRedoTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.Rendering.Tests | ||
{ | ||
partial class RenderingDebuggerTests | ||
{ | ||
private static void PerformUndoRedoGeneric<TDebugState, T>(UnityEngine.Rendering.DebugUI.IValueField field, T defaultValue, T valueToSet) | ||
where TDebugState : DebugState<T>, new() | ||
{ | ||
DebugState<T> state = ScriptableObject.CreateInstance<TDebugState>(); | ||
state.SetValue(defaultValue, field); | ||
|
||
Undo.RecordObject(state, nameof(PerformUndoRedoGeneric)); | ||
state.SetValue(valueToSet, field); | ||
|
||
Undo.PerformUndo(); | ||
Assert.AreEqual(defaultValue, state.value); | ||
|
||
Undo.PerformRedo(); | ||
Assert.AreEqual(valueToSet, state.value); | ||
} | ||
|
||
public class BitFieldTests<T> : UnityEngine.Rendering.DebugUI.BitField | ||
{ | ||
public BitFieldTests() | ||
{ | ||
enumType = typeof(T); | ||
} | ||
} | ||
|
||
public class AutoEnumFieldTest : UnityEngine.Rendering.DebugUI.EnumField | ||
{ | ||
public AutoEnumFieldTest() | ||
{ | ||
autoEnum = typeof(LightType); | ||
} | ||
} | ||
|
||
public class PathEnumFieldTest : UnityEngine.Rendering.DebugUI.EnumField | ||
{ | ||
public PathEnumFieldTest() | ||
{ | ||
enumNames = new GUIContent[] { new GUIContent("Item1"), new GUIContent("Catergory/Item1"), new GUIContent("Catergory/Item2") }; | ||
enumValues = new int[] { 0, 2, 4 }; | ||
} | ||
} | ||
|
||
static TestCaseData[] s_TestCaseDatas = | ||
{ | ||
new TestCaseData(typeof(DebugStateEnum), typeof(UnityEngine.Rendering.DebugUI.EnumField), typeof(int), 0, 2) | ||
.SetName("Undo/Redo works for Enums"), | ||
new TestCaseData(typeof(DebugStateEnum), typeof(AutoEnumFieldTest), typeof(int), LightType.Disc, LightType.Spot) | ||
.SetName("Undo/Redo works for Auto Enums"), | ||
new TestCaseData(typeof(DebugStateEnum), typeof(PathEnumFieldTest), typeof(int), 0, 4) | ||
.SetName("Undo/Redo works for Path Enums"), | ||
new TestCaseData(typeof(DebugStateBool), typeof(UnityEngine.Rendering.DebugUI.BoolField), typeof(bool), false, true) | ||
.SetName("Undo/Redo works for Booleans"), | ||
new TestCaseData(typeof(DebugStateColor), typeof(UnityEngine.Rendering.DebugUI.ColorField), typeof(Color), Color.green, Color.red) | ||
.SetName("Undo/Redo works for Colors"), | ||
new TestCaseData(typeof(DebugStateFloat), typeof(UnityEngine.Rendering.DebugUI.FloatField), typeof(float), 1.0f, 5.0f) | ||
.SetName("Undo/Redo works for Floats"), | ||
new TestCaseData(typeof(DebugStateInt), typeof(UnityEngine.Rendering.DebugUI.IntField), typeof(int), -1, 5) | ||
.SetName("Undo/Redo works for integers"), | ||
new TestCaseData(typeof(DebugStateUInt), typeof(UnityEngine.Rendering.DebugUI.UIntField), typeof(uint), 1u, 5u) | ||
.SetName("Undo/Redo works for unsigned integers"), | ||
new TestCaseData(typeof(DebugStateVector2), typeof(UnityEngine.Rendering.DebugUI.Vector2Field), typeof(Vector2), Vector2.zero, Vector2.up) | ||
.SetName("Undo/Redo works for vector 2"), | ||
new TestCaseData(typeof(DebugStateVector3), typeof(UnityEngine.Rendering.DebugUI.Vector3Field), typeof(Vector3), Vector3.zero, Vector3.up) | ||
.SetName("Undo/Redo works for vector 3"), | ||
new TestCaseData(typeof(DebugStateVector4), typeof(UnityEngine.Rendering.DebugUI.Vector4Field), typeof(Vector4), Vector4.zero, Vector4.one) | ||
.SetName("Undo/Redo works for vector 4"), | ||
new TestCaseData(typeof(DebugStateFlags), typeof(BitFieldTests<UnityEngine.Rendering.DebugUI.Flags>), typeof(Enum), UnityEngine.Rendering.DebugUI.Flags.EditorOnly, UnityEngine.Rendering.DebugUI.Flags.RuntimeOnly) | ||
.SetName("Undo/Redo works for bit fields"), | ||
}; | ||
|
||
[Test, TestCaseSource(nameof(s_TestCaseDatas))] | ||
public void PerformUndoRedo(Type debugStateType, Type widgetType, Type innerType, object defaultValue, object changeValue) | ||
{ | ||
var widget = Activator.CreateInstance(widgetType); | ||
var performUndoRedoGeneric = GetType() | ||
.GetMethod(nameof(PerformUndoRedoGeneric), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic) | ||
.MakeGenericMethod(new[] { debugStateType, innerType } ); | ||
|
||
object[] args = new object[] { widget, defaultValue, changeValue }; | ||
performUndoRedoGeneric.Invoke(null, args); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging/UndoRedoTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.