Introduction to USS built-in variables
Understand built-in USS variables and how to specify default values for Editor and runtime UI.
読み終わるまでの所要時間 5 分最終更新 21日前
USS built-in variables specify default values for Editor and runtime UI. You can use these variables in your own USS to match your custom interfaces with Unity style.
The name of each built-in variable indicates how and where the variable is used. A variable name consists of one or more parts, separated by hyphens. Each part consists of one or more words separated by underscores.
--unity-{group}-{role_and_control}-{sub_element}-{pseudo_state_sequence}Each part of the name shows the types of USS rules that use the variable.
- Group: The kind of data the variable represents.
- Role/Control: A conceptual grouping for the elements the variable affects.
- Sub-Element: An element or control the variable affects.
- Pseudo States: Lists the states Unity uses the variable for.
For example, the following variable name:
--unity-colors-button-text-hoverProvides the following information about how Unity uses the variable:
Value | Meaning | |
|---|---|---|
| Group | | Represents color data. |
| Role/Control | | Affects buttons. |
| Sub-Element | | Affects text. Its |
| Pseudo-States | | Applies to elements when the mouse pointer hovers over them. |
This USS built-in variable changes the color of button text when a user hovers over the button.
Group
The group specifies what kind of data the variable represents. Each group has several possible sub-elements.
The variable names have the following groups:
Group | Used for |
|---|---|
| Color properties, such as |
| Properties that control dimensions and shapes. For example, |
| Standard Unity icon images |
Role and Control
Roles and controls are two ways of grouping elements conceptually.
- Role refers to a group of elements that have the same purpose, regardless of what type each element is. For example, the role includes all elements that display error messages to users.
error - Control refers to a group of elements of the same type, regardless of what they do. For example, includes all buttons in the Editor.
buttons
Each variable has either a role or a control.
The variable names have the following roles and controls:
Roles
Role | Description |
|---|---|
| Default style settings such as text color, background, and margin. |
| Elements that display tabular data with alternating row colors. For example, list items in a list view. |
| Elements that communicate error states to users. |
| Highlighted parts of the UI. For example, text selections, or selected items in tree views. |
| Parts of the UI (typically text) that are clickable links. This is the un-clicked state. |
| Elements displayed when the Editor is in Play mode. |
| Parts of the UI, typically text, that are clickable links that a user has already clicked. |
| Elements that communicate a warning message to users. |
Controls
Control | Description |
|---|---|
| The main Unity toolbar |
| Buttons in the main Unity toolbar |
| Boxes used to group elements in the Editor UI |
| Buttons in the UI, except for toolbars |
| Dropdown lists or menus |
| Boxes used to display help information |
| Fields used to input text or numeric values |
| Text labels in the Editor UI |
| Fields used for object values. For example, property values for a GameObject or Asset. |
| Popup menu and other popup controls |
| Views used to display previews. For example, of Assets such as meshes and textures. |
| The background element of a scrollbar in which users drag the scrollbar thumb |
| The draggable handle element in a scrollbar |
| The background element of a slider in which users drag the slider thumb |
| The draggable handle element in a slider |
| An overlay displayed around the slider thumb when the user drags it |
| Tab items in tab controls |
| Any Editor toolbar except for the main Unity toolbar ( |
| Buttons in an Editor toolbar |
| Editor windows |
Sub-Element
The sub-element is the part of an element that the variable affects. Together with a variable's , the sub-element shows what kind of data the variable represents.
groupFor example, when you see a variable name with the group and the sub-element, it means Unity uses the variable in styles that affect text color.
colorstextThe variable names have the following sub-elements:
Colors group
Sub-element | Description |
|---|---|
| An element's background color |
| An element's outer border color |
| An element's inner border color. For example, Inspector windows have a two-tone border |
| Text color for elements that display text |
Metrics group
Sub-element | Description |
|---|---|
| An element's margin values |
| An element's padding values |
| An element's border width values |
| An element's border radius values values |
| An element's width and height values |
Pseudo-States
The pseudo-state sequence is a list of UI states that Unity uses a variable for.
For example, when you see a variable name with the pseudo state, it means Unity uses the variable in styles that affect elements when a user hovers the pointer over them.
hoverFor example: .
--unity-colors-toolbar_button-text-hoverA variable name can have more than one pseudo-state. Multiple pseudo states appear in alphabetical order, separated by underscores .
_For example: .
--unity-colors-toolbar_button-text-focus_selectedUnity variable names can have any combination of the following pseudo-states:
Pseudo-state | Description |
|---|---|
| (none) | Normal state |
| A checkbox-type control is checked |
| A control is disabled |
| A control has focus |
| A user hovers over a control |
| A control doesn't have focus |
| A control is pressed |
| A control is selected |