Implement some runtime GUI layout and functional aid methods. More...
Static Public Member Functions | |
static bool | CheckFocus (int id=0, params KeyCode[] keys) |
Check if currently focus on a text field, and unfocus if click outside or press ESC key. More... | |
static void | PrefixLabel (GUIContent label) |
Draw prefix label without width expanding nor line breaking. More... | |
static string | TextArea (GUIContent label, string text, params GUILayoutOption[] options) |
Draw multiline text field with prefix label. More... | |
static bool | Toggle (GUIContent label, bool value, params GUILayoutOption[] options) |
Draw bool toggle with prefix label, and the value string behind. More... | |
static int | IntField (GUIContent label, int value, int min=0, int max=0, params GUILayoutOption[] options) |
Draw int field with limited slider, or shuttle if limitations are the same. More... | |
static float | FloatField (GUIContent label, float value, float min=0f, float max=0f, params GUILayoutOption[] options) |
Draw float field with limited slider, or shuttle if limitations are the same. More... | |
static void | MultiIntField (GUIContent label, GUIContent[] subLabels, int[] values, params GUILayoutOption[] options) |
Draw multiple IntField() in one line with paired sub labels and values. More... | |
static void | MultiFloatField (GUIContent label, GUIContent[] subLabels, float[] values, params GUILayoutOption[] options) |
Draw multiple FloatField() in one line with paired sub labels and values. More... | |
static Vector2 | Vector2Field (GUIContent label, Vector2 value, params GUILayoutOption[] options) |
Draw UnityEngine.Vector2 field with 2 FloatField() in one line. More... | |
static Vector3 | Vector3Field (GUIContent label, Vector3 value, params GUILayoutOption[] options) |
Draw UnityEngine.Vector3 field with 3 FloatField() in one line. More... | |
static Vector4 | Vector4Field (GUIContent label, Vector4 value, params GUILayoutOption[] options) |
Draw UnityEngine.Vector4 field with 4 FloatField() in one line. More... | |
static Quaternion | QuaternionField (GUIContent label, Quaternion value, params GUILayoutOption[] options) |
Draw UnityEngine.Quaternion field with 4 FloatField() in one line. More... | |
static Rect | RectField (GUIContent label, Rect value, params GUILayoutOption[] options) |
Draw UnityEngine.Rect field with 4 FloatField() in one line. More... | |
static RectOffset | RectOffsetField (GUIContent label, RectOffset value, params GUILayoutOption[] options) |
Draw UnityEngine.RectOffset field with 4 IntField() in one line. More... | |
static Bounds | BoundsField (GUIContent label, Bounds value, params GUILayoutOption[] options) |
Draw UnityEngine.Bounds field with 2 lines of Vector3Field() . More... | |
static Matrix4x4 | Matrix4x4Field (GUIContent label, Matrix4x4 value, params GUILayoutOption[] options) |
Draw UnityEngine.Matrix4x4 field in 4 lines, each has 4 FloatField() . More... | |
static Color | ColorField (GUIContent label, Color value, params GUILayoutOption[] options) |
Draw UnityEngine.Color field with preview and 4 sliders to tweak RGBA or HSVA. More... | |
static T | EnumRadio< T > (GUIContent label, T value, params GUILayoutOption[] options) |
Draw radio toggles to select enum. More... | |
static T | EnumMaskRadio< T > (GUIContent label, T value, params GUILayoutOption[] options) |
Draw radio toggles to multi select mask enum. More... | |
static T | ValueField< T > (GUIContent label, T value, params GUILayoutOption[] options) |
Draw the value field formatted by the value type. More... | |
static T | TextField< T > (GUIContent label, T value, params GUILayoutOption[] options) |
Draw the text field to display JSON serialized value. More... | |
static Vector2 | GUIToScreenPoint (Vector2 guiPoint) |
Convert a point from GUI position to screen space. More... | |
static Vector2 | ScreenToGUIPoint (Vector2 screenPoint) |
Convert a point from screen space to GUI position. More... | |
static void | DrawLine (Vector2 start, Vector2 end, Color color=default, float width=2f) |
Draw a line from the start point to the end, with specified color and line width. More... | |
static void | DrawPolygon (Color color, float width, bool close, params Vector2[] points) |
Draw a polygon connects all points with color and line width, optional to close it. More... | |
static void | DrawPolygon (bool close, params Vector2[] points) |
Draw a polygon connects all points, optional to close it. More... | |
static void | DrawBorder (Rect rect, Color color=default, float width=2f) |
Draw a border, empty rect with 4 lines. More... | |
Implement some runtime GUI layout and functional aid methods.
|
static |
Check if currently focus on a text field, and unfocus if click outside or press ESC key.
Optional to assign extra keys to unfocus besides escape key. If specify control ID, check extra keys only if focus on it now, and return if still focused. Otherwise, check extra keys whenever key down, and return if any text control focused.
id | Control ID. |
keys | Keys to unfocus when press. |
true
, if focused, false
otherwise.
|
static |
Draw prefix label without width expanding nor line breaking.
label | Label. |
|
static |
Draw multiline text field with prefix label.
Unfocus if click outside or press escape key. This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
text | Text value. |
options | Layout options. |
|
static |
Draw bool
toggle with prefix label, and the value string
behind.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw int
field with limited slider, or shuttle if limitations are the same.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
min | Min value to clamp. |
max | Max value to clamp. |
options | Layout options. |
|
static |
Draw float
field with limited slider, or shuttle if limitations are the same.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
min | Min value to clamp. |
max | Max value to clamp. |
options | Layout options. |
|
static |
Draw multiple IntField()
in one line with paired sub labels and values.
The edited results will be set back to the values array. This applies options to horizontal group, may cause 4px more than normal above and below.
label | Main label. |
subLabels | Sub labels. |
values | Values array. |
options | Layout options. |
|
static |
Draw multiple FloatField()
in one line with paired sub labels and values.
The edited results will be set back to the values array. This applies options to horizontal group, may cause 4px more than normal above and below.
label | Main label. |
subLabels | Sub labels. |
values | Values array. |
options | Layout options. |
|
static |
Draw UnityEngine.Vector2
field with 2 FloatField()
in one line.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Vector3
field with 3 FloatField()
in one line.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Vector4
field with 4 FloatField()
in one line.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Quaternion
field with 4 FloatField()
in one line.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Rect
field with 4 FloatField()
in one line.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.RectOffset
field with 4 IntField()
in one line.
This will return new instance although it's class
. This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Bounds
field with 2 lines of Vector3Field()
.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Matrix4x4
field in 4 lines, each has 4 FloatField()
.
This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw UnityEngine.Color
field with preview and 4 sliders to tweak RGBA or HSVA.
Click preview field to switch color mode. This applies options to horizontal group, may cause 4px more than normal above and below.
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw radio toggles to select enum.
This applies options to horizontal group, may cause 4px more than normal above and below.
T | The enum type. |
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw radio toggles to multi select mask enum.
This applies options to horizontal group, may cause 4px more than normal above and below.
T | The enum type. |
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw the value field formatted by the value type.
If it is an array and the length is changed on GUI, this will return a new instance. Note, unassigned T
becomes object
if pass value null
.
It's able to make a custom layout for a custom type, instead of default as a text field. Just make a class implements IAidDrawer
, this'll find it to draw the GUI. Note, this instantiates the custom drawer by the default constructor. E.g., the classes below aren't allowed to implement:
UnityEngine.MonoBehaviour
.UnityEngine.ScriptableObject
. T | The value type. |
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Draw the text field to display JSON serialized value.
Use temporary content if focused, highlight if different from the original. Unfocus if click outside, press escape or enter key. Note, this will return new deserialized value instance if changed, otherwise original. This applies options to horizontal group, may cause 4px more than normal above and below.
T | The value type. |
label | Label. |
value | Value. |
options | Layout options. |
|
static |
Convert a point from GUI position to screen space.
guiPoint | GUI point. |
|
static |
Convert a point from screen space to GUI position.
The result is the same as Event.mousePosition
if assigning Input.mousePosition
.
screenPoint | Screen point. |
|
static |
Draw a line from the start point to the end, with specified color and line width.
start | Start point. |
end | End point. |
color | Line color. |
width | Line width. |
|
static |
Draw a polygon connects all points with color and line width, optional to close it.
color | Line color. |
width | Line width. |
close | If set to true close. |
points | Points. |
|
static |
Draw a polygon connects all points, optional to close it.
close | If set to true close. |
points | Points. |
|
static |
Draw a border, empty rect with 4 lines.
rect | Rect. |
color | Line color. |
width | Line width. |