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 9e9b2839b3c..b2b3fc53985 100644
--- a/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs
+++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugUIDrawer.Builtins.cs
@@ -654,6 +654,81 @@ public override bool OnGUI(DebugUI.Widget widget, DebugState state)
}
}
+ ///
+ /// Builtin Drawer for Items.
+ ///
+ [DebugUIDrawer(typeof(DebugUI.ObjectField))]
+ public sealed class DebugUIDrawerObjectField : DebugUIDrawer
+ {
+ ///
+ /// OnGUI implementation for Object DebugUIDrawer.
+ ///
+ /// DebugUI .
+ /// Debug State associated with the Debug Item.
+ /// The state of the widget.
+ public override bool OnGUI(DebugUI.Widget widget, DebugState state)
+ {
+ var w = Cast(widget);
+
+ EditorGUI.BeginChangeCheck();
+
+ var rect = PrepareControlRect();
+ var value = EditorGUI.ObjectField(rect, EditorGUIUtility.TrTextContent(w.displayName, w.tooltip), w.GetValue(), w.type, true);
+
+ if (EditorGUI.EndChangeCheck())
+ Apply(w, state, value);
+
+ return true;
+ }
+ }
+
+ ///
+ /// Builtin Drawer for Items.
+ ///
+ [DebugUIDrawer(typeof(DebugUI.ObjectListField))]
+ public sealed class DebugUIDrawerObjectListField : DebugUIDrawer
+ {
+ ///
+ /// OnGUI implementation for ObjectList DebugUIDrawer.
+ ///
+ /// DebugUI .
+ /// Debug State associated with the Debug Item.
+ /// The state of the widget.
+ public override bool OnGUI(DebugUI.Widget widget, DebugState state)
+ {
+ var w = Cast(widget);
+ var objects = w.GetValue();
+
+ float height = Math.Max(objects != null ? objects.Length : 0, 1) * DebugWindow.Styles.singleRowHeight;
+ var rect = PrepareControlRect(height);
+
+ rect = EditorGUI.PrefixLabel(rect, EditorGUIUtility.TrTextContent(widget.displayName));
+
+ EditorGUI.BeginChangeCheck();
+ DoObjectList(rect, w, objects);
+ if (EditorGUI.EndChangeCheck())
+ Apply(w, state, objects);
+
+ return true;
+ }
+
+ internal static void DoObjectList(Rect rect, DebugUI.ObjectListField widget, UnityEngine.Object[] objects)
+ {
+ if (objects == null || objects.Length == 0)
+ {
+ EditorGUI.LabelField(rect, GUIContent.none, EditorGUIUtility.TrTextContent("Empty"));
+ return;
+ }
+
+ rect.height = EditorGUIUtility.singleLineHeight;
+ for (int i = 0; i < objects.Length; i++)
+ {
+ objects[i] = EditorGUI.ObjectField(rect, GUIContent.none, objects[i], widget.type, true);
+ rect.y += DebugWindow.Styles.singleRowHeight;
+ }
+ }
+ }
+
///
/// Builtin Drawer for MessageBox Items.
///
@@ -782,14 +857,21 @@ public sealed class DebugUIDrawerTable : DebugUIDrawer
/// The state of the widget.
public override bool OnGUI(DebugUI.Widget widget, DebugState state)
{
+ const float k_ScrollBarHeight = 15;
+
var w = Cast(widget);
var header = w.Header;
+ var visible = header.state.visibleColumns;
+
+ float contentHeight = 0.0f;
+ foreach (DebugUI.Table.Row row in w.children)
+ contentHeight += row != null ? GetRowHeight(row, visible) : EditorGUIUtility.singleLineHeight;
// Put some space before the array
PrepareControlRect(EditorGUIUtility.singleLineHeight * 0.5f);
// Draw an outline around the table
- var rect = EditorGUI.IndentedRect(PrepareControlRect(header.height + (w.children.Count + 1) * EditorGUIUtility.singleLineHeight));
+ var rect = EditorGUI.IndentedRect(PrepareControlRect(header.height + contentHeight + k_ScrollBarHeight));
rect = DrawOutline(rect);
// Compute rects
@@ -797,8 +879,7 @@ public override bool OnGUI(DebugUI.Widget widget, DebugState state)
var contentRect = new Rect(rect.x, headerRect.yMax, rect.width, rect.height - headerRect.height);
var viewRect = new Rect(contentRect.x, contentRect.y, header.state.widthOfAllVisibleColumns, contentRect.height);
var rowRect = contentRect;
- rowRect.height = EditorGUIUtility.singleLineHeight;
- viewRect.height -= EditorGUIUtility.singleLineHeight;
+ viewRect.height -= k_ScrollBarHeight;
// Show header
header.OnGUI(headerRect, Mathf.Max(w.scroll.x, 0f));
@@ -807,24 +888,27 @@ public override bool OnGUI(DebugUI.Widget widget, DebugState state)
w.scroll = GUI.BeginScrollView(contentRect, w.scroll, viewRect);
{
var columns = header.state.columns;
- var visible = header.state.visibleColumns;
for (int r = 0; r < w.children.Count; r++)
{
var row = Cast(w.children[r]);
rowRect.x = contentRect.x;
rowRect.width = columns[0].width;
+ rowRect.height = (row is DebugUI.Table.Row tableRow) ? GetRowHeight(tableRow, visible) : EditorGUIUtility.singleLineHeight;
rowRect.xMin += 2;
rowRect.xMax -= 2;
- EditorGUI.LabelField(rowRect, GUIContent.none, EditorGUIUtility.TrTextContent(row.displayName));
+ EditorGUI.LabelField(rowRect, GUIContent.none, EditorGUIUtility.TrTextContent(row.displayName), DebugWindow.Styles.centeredLeft);
rowRect.xMin -= 2;
rowRect.xMax += 2;
- for (int c = 1; c < visible.Length; c++)
+ using (new EditorGUI.DisabledScope(w.isReadOnly))
{
- rowRect.x += rowRect.width;
- rowRect.width = columns[visible[c]].width;
- DisplayChild(rowRect, row.children[visible[c] - 1], w.isReadOnly);
+ for (int c = 1; c < visible.Length; c++)
+ {
+ rowRect.x += rowRect.width;
+ rowRect.width = columns[visible[c]].width;
+ DisplayChild(rowRect, row.children[visible[c] - 1]);
+ }
}
rowRect.y += rowRect.height;
}
@@ -834,6 +918,19 @@ public override bool OnGUI(DebugUI.Widget widget, DebugState state)
return false;
}
+ internal float GetRowHeight(DebugUI.Table.Row row, int[] visibleColumns)
+ {
+ float height = EditorGUIUtility.singleLineHeight;
+ for (int c = 1; c < visibleColumns.Length; c++)
+ {
+ var child = row.children[visibleColumns[c] - 1] as DebugUI.ObjectListField;
+ if (child == null || child.GetValue() == null)
+ continue;
+ height = Mathf.Max(height, child.GetValue().Length * DebugWindow.Styles.singleRowHeight);
+ }
+ return height;
+ }
+
internal Rect DrawOutline(Rect rect)
{
if (Event.current.type != EventType.Repaint)
@@ -853,7 +950,7 @@ internal Rect DrawOutline(Rect rect)
return new Rect(rect.x + size, rect.y + size, rect.width - 2 * size, rect.height - 2 * size);
}
- internal void DisplayChild(Rect rect, DebugUI.Widget child, bool disable)
+ internal void DisplayChild(Rect rect, DebugUI.Widget child)
{
rect.xMin += 2;
rect.xMax -= 2;
@@ -865,14 +962,22 @@ internal void DisplayChild(Rect rect, DebugUI.Widget child, bool disable)
else if (child.GetType() == typeof(DebugUI.ColorField))
{
var widget = Cast(child);
- using (new EditorGUI.DisabledScope(disable))
- EditorGUI.ColorField(rect, GUIContent.none, widget.GetValue(), false, widget.showAlpha, widget.hdr);
+ EditorGUI.ColorField(rect, GUIContent.none, widget.GetValue(), false, widget.showAlpha, widget.hdr);
}
else if (child.GetType() == typeof(DebugUI.BoolField))
{
var widget = Cast(child);
- using (new EditorGUI.DisabledScope(disable))
- EditorGUI.Toggle(rect, GUIContent.none, widget.GetValue());
+ EditorGUI.Toggle(rect, GUIContent.none, widget.GetValue());
+ }
+ else if (child.GetType() == typeof(DebugUI.ObjectField))
+ {
+ var widget = Cast(child);
+ EditorGUI.ObjectField(rect, GUIContent.none, widget.GetValue(), widget.type, true);
+ }
+ else if (child.GetType() == typeof(DebugUI.ObjectListField))
+ {
+ var widget = Cast(child);
+ DebugUIDrawerObjectListField.DoObjectList(rect, widget, widget.GetValue());
}
}
}
diff --git a/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs b/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs
index 83b39d332c8..1d7c1525709 100644
--- a/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs
+++ b/com.unity.render-pipelines.core/Editor/Debugging/DebugWindow.cs
@@ -562,6 +562,9 @@ public class Styles
public readonly GUIStyle sectionHeader = new GUIStyle(EditorStyles.largeLabel);
public readonly Color skinBackgroundColor;
+ public static GUIStyle centeredLeft = new GUIStyle(EditorStyles.label) { alignment = TextAnchor.MiddleLeft };
+ public static float singleRowHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
+
public static int foldoutColumnWidth = 70;
public Styles()
diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs b/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs
index cd7fcf7101d..a084f493b1b 100644
--- a/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs
+++ b/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs
@@ -527,6 +527,28 @@ public class Vector4Field : Field
public int decimals = 3;
}
+ ///
+ /// Object field.
+ ///
+ public class ObjectField : Field