The Editor includes these variations of buttons:
The basic button initiates a specific action once selected. Once basic button actions are performed their task is complete.
In the Editor, destructive buttons are aligned on the left, and secondary / primary buttons are aligned on the right hand side of the panel they are displayed in.
Editor API for dialogs display the native operating system dialog.
Buttons come in three sizes in the IMGUI framework:
1. Default button: .Button
2. Large button: .LargeButton
3. Mini button: .minibutton
When grouping toggle buttons in the IMGUI framework, use these parameters to adjust left / right borders and margins:
1. Leftmost button: .ButtonLeft
2. Middle button: .ButtonMid
3. Rightmost button: .ButtonRight
Buttons use labels to indicate their function and can be either a basic button or toggle button. Text buttons rely on words to express concepts that cannot be easily conveyed by icons or glyphs in an accessible manner. Buttons have text labels that should clearly and concisely indicate what action they perform.
Buttons visually communicate their interaction, by changing their state to convey that an action is being performed or is completed.
Because some buttons can relate to an action or process that can be performed multiple times, a button may return to its default state after it is pressed but will still play an animation to convey it has been used.
A button can contain the following elements:
1. Label
2. Icon
3. Container
Height and padding specs for three sizes:
1. Mini Button: height is 18px, padding is 2 px
2. Default Button: height is 20px, padding is 3px
3. Large Button: height is 24px, padding is 5px
The default state is the pre-interaction state.
When the cursor is over the button element.
When the interaction is occurring or active, such as a menu being open or toggling a property.
When the user has highlighted the active button element.
When the user has highlighted the default button element.
When the cursor is over the focused button element.
When the interaction is not available to the user.
A button's state will vary depending on the state of the action it is performing and whether the action is available or not.
Go to Window > UI Toolkit > Samples to view code samples in C# / USS / UXML.
IMGUI
Unity - Scripting API:
GUI.Button
UnityEngine.GUI.Toggle (+styles)
UnityEngine.GUILayout.
Toolbar (+styles)