A single numeric field
Use Single Fields for inputing a single data point in numeric fields.
A multi numeric field
Use Multi Fields for inputting multiple data points in numeric fields.
Numeric fields work best for making small, incremental changes that require precise input. When large, imprecise value changes are expected, pair Numeric Fields with sliders.
Ensure that a default value is always shown in the field where possible.
Single numeric fields:
When paired with a basic slider, numeric fields are positioned to the right of the Slider.
Min/max numeric fields:
When paired with a min/max slider, numeric fields are positioned on both sides of the Slider, to represent the minimum and maximum values.
Numeric fields are an adjustment-based control element, where the numerical value in the field determines its value.
When a value that is invalid for the property is entered, input fields show last valid value.
EditorGUI.Delayed
IntField
EditorGUI.Delayed
FloatField
EditorGUI.Delayed
DoubleField
Scripting API for text field for entering integers.
Scripting API for text field for entering floats.
Scripting API for text field for entering doubles.
A numeric field can contain and be paired with the following elements:
1. Control label
2. View
3. Body (container)
Labels should be placed to the left of the numeric field, such as X Y Z coordinate labels in Vector3 fields. Labels should be simple and clear, relating to the nature of content.
The view of a numeric field is the space within the body (container) where content is displayed.
The body of a dynamic, scalable text box spans the width of the window it occupies, maintaining a thin margin on either side.
When resizing a row with a numeric field horizontally, internal paddings and margins remain the same but the width of the body (container) scales to fit the new width.
Default state of a Numeric Field.
When hovering over a numeric field body the border will be highlighted. Additionally, the user’s default cursor will switch to a Line Cursor glyph to indicate the nature of the element.
When a numeric field enters the Focused state its content will be highlighted in addition to its borders. This is because the content is being selected, allowing for the user to interact with it immediately (for example by immediately deleting or copying all of it).
A numeric field that is disabled will indicate so by having its body “greyed out” and will not accept inputs or react to hovering.
Go to Window > UI Toolkit > Samples, to view code samples in C# / USS / UXML.
UI Toolkit
Unity - Scripting API:
DoubleField
Unity - Scripting API:
FloatField
Unity - Scripting API:
IntegerField
Unity - Scripting API:
LongField
UI Toolkit
Unity - Scripting API:
BoundsField
Unity - Scripting API:
BoundsIntField
Unity - Scripting API:
Vector2Field
Unity - Scripting API:
Vector2IntField
Unity - Scripting API:
Vector3Field
Unity - Scripting API:
Vector3IntField
Unity - Scripting API:
Vector4Field
Unity - Scripting API:
RectField
Unity - Scripting API:
RectIntField
IMGUI
Unity - Scripting API:
EditorGUI.BoundsField
Unity - Scripting API:
EditorGUI.BoundsIntField
Unity - Scripting API:
EditorGUI.Vector2Field
Unity - Scripting API:
EditorGUI.Vector2IntField
Unity - Scripting API:
EditorGUI.Vector3Field
Unity - Scripting API:
EditorGUI.Vector3IntField
Unity - Scripting API:
EditorGUI.Vector4Field
Unity - Scripting API:
EditorGUI.RectField
Unity - Scripting API:
EditorGUI.RectIntField