Class WorkshopGUI
- Namespace
- TDMaker.Editor
- Assembly
- TDMaker.Editor.dll
IMGUI helpers of the Unit Workshop: flat forms (nested data drawn as labelled blocks instead of nested foldouts, with
enabled / useX switches hiding what is off), cards and small drawing utilities.
public static class WorkshopGUI
- Inheritance
-
WorkshopGUI
- Inherited Members
Fields
DefaultLabelWidth
Label column width of an editor window when nothing sets it (Unity's default outside inspectors).
public const float DefaultLabelWidth = 150
Field Value
IndentWidth
Indent of one UnityEditor.EditorGUI.indentLevel step.
public const float IndentWidth = 15
Field Value
Properties
Card
Card body style.
public static GUIStyle Card { get; }
Property Value
- GUIStyle
CardTitle
Card title style.
public static GUIStyle CardTitle { get; }
Property Value
- GUIStyle
RowLabel
List row label.
public static GUIStyle RowLabel { get; }
Property Value
- GUIStyle
SectionLabel
Header of a nested block inside a flat form.
public static GUIStyle SectionLabel { get; }
Property Value
- GUIStyle
TabButton
Tab button.
public static GUIStyle TabButton { get; }
Property Value
- GUIStyle
Methods
BeginCard(string, Color, string)
Begins a card with a coloured edge and a title; returns the header rect (for buttons drawn on the right).
public static Rect BeginCard(string title, Color color, string subtitle = null)
Parameters
Returns
- Rect
Children(SerializedProperty, int, params string[])
Draws every visible child of a block flat, skipping skip and payloads whose useX switch is off.
public static void Children(SerializedProperty block, int depth = 0, params string[] skip)
Parameters
DrawSprite(Rect, Sprite, bool, Color)
Draws a sprite into a rect (texture-space UVs, optional horizontal mirror and tint).
public static void DrawSprite(Rect rect, Sprite sprite, bool mirror, Color tint)
Parameters
rectRectspriteSpritemirrorbooltintColor
EndCard()
Ends a card.
public static void EndCard()
Fields(SerializedObject, params string[])
Draws the named properties of so as a flat form.
public static void Fields(SerializedObject so, params string[] names)
Parameters
soSerializedObjectnamesstring[]
FitLabelWidth(float, float, float, float)
Label column width that fits a label of widest pixels: never below min and never more
than maxFraction of the available width (the fields keep the rest).
public static float FitLabelWidth(float widest, float available, float min = 150, float maxFraction = 0.5)
Parameters
Returns
Flat(SerializedProperty, string, int)
Draws one property flat: nested classes become a small header plus their fields (one indent level, no foldout), lists keep
the standard list drawer. A class with an enabled switch shows only the switch while it is off.
public static void Flat(SerializedProperty p, string label = null, int depth = 0)
Parameters
HeaderButtons(Rect, bool, bool, bool, bool)
Small icon buttons at the right of a card header; returns -1 (none), 0 (up), 1 (down), 2 (remove). Cards whose place is
fixed by the data (traits stored as separate fields) pass showMove false and get no arrows at all.
public static int HeaderButtons(Rect header, bool canUp, bool canDown, bool canRemove = true, bool showMove = true)
Parameters
Returns
IsBlock(SerializedProperty)
Whether a property is a nested serializable class drawn as a block.
public static bool IsBlock(SerializedProperty p)
Parameters
pSerializedProperty
Returns
MeasureLabel(string)
Pixel width of a label text in the standard label style (an estimate when no GUI skin is loaded, e.g. in batch mode).
public static float MeasureLabel(string text)
Parameters
textstring
Returns
Num(double, string)
Formats a time or count that may be infinite.
public static string Num(double value, string format = "0.#")
Parameters
Returns
Relative(SerializedProperty, params string[])
Draws the named relative children of parent as a flat form.
public static void Relative(SerializedProperty parent, params string[] names)
Parameters
parentSerializedPropertynamesstring[]
Row(string[], float[], GUIStyle, Color?)
Draws a row of table cells with relative widths.
public static void Row(string[] cells, float[] widths, GUIStyle style = null, Color? tint = null)
Parameters
SpriteRect(Sprite, Vector2, float, float, bool)
Screen rect of a sprite drawn with its pivot at pivotScreen and pixelsPerWorld zoom
(sprite size from its pixels per unit, times scale). Mirroring flips around the pivot.
public static Rect SpriteRect(Sprite sprite, Vector2 pivotScreen, float pixelsPerWorld, float scale, bool mirror)
Parameters
Returns
- Rect
Stat(string, string, bool)
A label/value row with an optional warning tint.
public static void Stat(string label, string value, bool warn = false)
Parameters
WidestLabel(SerializedObject, Func<string, float>)
Width the label column needs for every visible property of so: the label text measured with
measure plus its indent. Nested blocks count one indent each; list elements do not (forms draw them as
cards at the list's indent), and one spare indent covers cards that indent their content.
public static float WidestLabel(SerializedObject so, Func<string, float> measure)