/// <summary> /// End implementation for Horizontal Box DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> public override void End(DebugUI.Widget widget, DebugState state) { EditorGUILayout.EndHorizontal(); }
/// <summary> /// End implementation for Container DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> public override void End(DebugUI.Widget widget, DebugState state) { EditorGUI.indentLevel--; }
/// <summary> /// Begin implementation for Horizontal Box DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> public override void Begin(DebugUI.Widget widget, DebugState state) { EditorGUILayout.BeginHorizontal(); }
/// <summary> /// OnGUI implementation for History Enum DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> /// <returns>The state of the widget.</returns> public override bool OnGUI(DebugUI.Widget widget, DebugState state) { var w = Cast <DebugUI.HistoryEnumField>(widget); var s = Cast <DebugStateInt>(state); if (w.indexes == null) { w.InitIndexes(); } EditorGUI.BeginChangeCheck(); int index = -1; int value = w.GetValue(); if (w.enumNames == null || w.enumValues == null) { EditorGUILayout.LabelField("Can't draw an empty enumeration."); } else { var rect = PrepareControlRect(); index = w.currentIndex; // Fallback just in case, we may be handling sub/sectionned enums here if (index < 0) { index = 0; } var labelRect = rect; labelRect.width = EditorGUIUtility.labelWidth; const int oneValueWidth = 70; var valueRects = new Rect[w.historyDepth + 1]; for (int i = 0; i < w.historyDepth + 1; i++) { valueRects[i] = rect; valueRects[i].x += EditorGUIUtility.labelWidth + i * oneValueWidth; valueRects[i].width = oneValueWidth; } EditorGUI.LabelField(labelRect, EditorGUIUtility.TrTextContent(w.displayName)); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; //be at left of rects index = EditorGUI.IntPopup(valueRects[0], index, w.enumNames, w.indexes); value = w.enumValues[index]; using (new EditorGUI.DisabledScope(true)) { for (int i = 0; i < w.historyDepth; i++) { EditorGUI.IntPopup(valueRects[i + 1], w.GetHistoryValue(i), w.enumNames, w.indexes); } } EditorGUI.indentLevel = indent; } if (EditorGUI.EndChangeCheck()) { Apply(w, s, value); if (index > -1) { w.currentIndex = index; } } return(true); }
/// <summary> /// OnGUI implementation for Foldout DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> /// <returns>The state of the widget.</returns> public override bool OnGUI(DebugUI.Widget widget, DebugState state) { var s = Cast <DebugStateBool>(state); return(s.value); }
/// <summary> /// Implement this to execute processing after UI rendering. /// </summary> /// <param name="widget">Widget that is going to be rendered.</param> /// <param name="state">Debug State associated with the Debug Item.</param> public virtual void End(DebugUI.Widget widget, DebugState state) { }
/// <summary> /// Implement this to execute UI rendering. /// </summary> /// <param name="widget">Widget that is going to be rendered.</param> /// <param name="state">Debug State associated with the Debug Item.</param> /// <returns>Returns the state of the widget.</returns> public virtual bool OnGUI(DebugUI.Widget widget, DebugState state) { return(true); }
/// <summary> /// Implement this to execute processing before UI rendering. /// </summary> /// <param name="widget">Widget that is going to be rendered.</param> /// <param name="state">Debug State associated with the Debug Item.</param> public virtual void Begin(DebugUI.Widget widget, DebugState state) { }
/// <summary> /// OnGUI implementation for Table DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> /// <returns>The state of the widget.</returns> public override bool OnGUI(DebugUI.Widget widget, DebugState state) { const float k_ScrollBarHeight = 15; var w = Cast <DebugUI.Table>(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 + contentHeight + k_ScrollBarHeight)); rect = DrawOutline(rect); // Compute rects var headerRect = new Rect(rect.x, rect.y, rect.width, header.height); 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; viewRect.height -= k_ScrollBarHeight; // Show header header.OnGUI(headerRect, Mathf.Max(w.scroll.x, 0f)); // Show array content w.scroll = GUI.BeginScrollView(contentRect, w.scroll, viewRect); { var columns = header.state.columns; for (int r = 0; r < w.children.Count; r++) { var row = Cast <DebugUI.Container>(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), DebugWindow.Styles.centeredLeft); rowRect.xMin -= 2; rowRect.xMax += 2; using (new EditorGUI.DisabledScope(w.isReadOnly)) { for (int c = 1; c < visible.Length; c++) { rowRect.x += rowRect.width; rowRect.width = columns[visible[c]].width; if (!row.isHidden) { DisplayChild(rowRect, row.children[visible[c] - 1]); } } rowRect.y += rowRect.height; } } } GUI.EndScrollView(false); return(false); }
/// <summary> /// OnGUI implementation for Foldout DebugUIDrawer. /// </summary> /// <param name="widget">DebugUI Widget.</param> /// <param name="state">Debug State associated with the Debug Item.</param> /// <returns>The state of the widget.</returns> public override bool OnGUI(DebugUI.Widget widget, DebugState state) { var w = Cast <DebugUI.Foldout>(widget); return(w.opened); }