Color Variables
Themes
The Unity Editor is available in two themes: light and dark. Theme selection is a personal preference. Users spend many hours in the Editor and using an appropriate theme option can greatly reduce eye strain in a given environment.
Variables
A variable is an identifier in the code that assigns a value. Colors are implemented using color variables so they can be easily changed. For example, each color variable has a light and dark value so that when the Editor theme is changed the UI will automatically update to the correct theme.
Avoid using hard-coded colors in Editor UI as hard-coded values will not change when colors are updated. Always style UI for the Editor using color variables rather than hexadecimal or RGBA color values directly. Many pre-existing variables are available. However, new variables can be created as needed.
Unity Variable Names
Unity uses a specific naming convention for built-in variables to indicate how they are used. A variable name consists of one or more parts, separated by hyphens. Each part consists of one or more words separated by underscores.
Example of variable naming:
--unity-{group}-{role_and_control}-{sub_element}-{pseudo_state_sequence}
For example, the following variable name --unity-colors-button-text-hover provides the following information about how Unity uses the variable:
Group (colors)
colors
The variable represents color data
Role/Control (button)
button
The variable affects buttons
Sub-Element (text)
text
The variable affects text. Because its group is colors, you know it affects text color
Pseudo-States (hover)
hover
Unity uses the variable in styles that it applies to elements when the mouse pointer hovers over them
For more about built-in Unity variables go to Unity’s built-in style sheets
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 hover pseudo-state, it means Unity uses the variable in styles that affect elements when a user hovers the mouse pointer over them.
Example: --unity-colors-toolbar_button-text-hover
A variable name can have more than one pseudo-state. Multiple pseudo-states appear in alphabetical order, separated by underscores.
Example: --unity-colors-toolbar_button-text-focus_selected
Unity variable names can have any combination of the following pseudo-states:
A control is checked (like a check-box)
A user hovers over a control
A control does not have focus
Flat Design
Unity Editor follows flat design principles
Avoid using shadows excessively to add depth to the UI. Instead use accented borders and base layers to add depth to your designs.
While the Unity Editor as a whole follows principles of flat UI design, it introduces depth using different principles:
- Accented borders
- Inset and outset controls
- Base layers of background colors
Accented Borders
Accent borders are designed to inset and outset UI to support the layering of the user interface. This subtle increase in control differentiation has a considerable impact on usability. For example, the text field control is inset and has a different top border color.
Base Layers
Colors in the Editor are designed to leverage the real world of tactile objects and physical layering. Layers, like sheets of paper on a desk, are arranged one on top of another. This layering of UI and color is designed to support the information architecture and visual organization of content for optimal usability. Colors are layered from dark to light according to three base layers:
Base 1 - Application Bar and Controls
Base 2 - Components and Windows
Base 3 - Toolbars and Toolbar Controls
Color variables in Frameworks
Color variables documented here are only applicable in IMGUI and UI Toolkit frameworks and are not intended to be used in Runtime.
Base 2
Dropdown (Pop-up) Colors
Dropdown / pop-up in dark theme.
--unity-colors-dropdown-background
The background color for a dropdown control
Dropdown Background Hover
--unity-colors-dropdown-background-hover
The background color for a dropdown control when the mouse pointer hovers over it
--unity-colors-dropdown-border
The border color for a dropdown control
--unity-colors-dropdown-border_accent
The border accent color for a dropdown control
--unity-colors-dropdown-text
The text color for a dropdown control
For more information go to Dropdowns ->
Help Boxes
Shader channels helpbox.
--unity-colors-helpbox-background
The background color for a helpbox control
rgba(235, 235, 235, 0.2039216)
rgba(96, 96, 96, 0.2039216)
--unity-colors-helpbox-border
The border color for a helpbox control
--unity-colors-helpbox-text
The text color for a helpbox control
For more information go to Dropdowns ->
Multi Column Header
--unity-colors-headerbar-background
The background color for a header bar control
Header Bar Column Control Background
--unity-colors-headerbar_column-background
The background color used for a column control in a header bar
Header Bar Column Control Background Hover
--unity-colors-headerbar_column-background-hover
The background color used for a button control when hovered over
Header Bar Column Control Background Pressed
--unity-colors-headerbar_column-background-pressed
The background color used for a button control when pressed
Object Field Colors
--unity-colors-object_field-background
The background color for an object field control
--unity-colors-object_field-border
The border color for an object field control
Object Field Border Focus
--unity-colors-object_field-border-focus
The border color for an object field control when it has focus
Object Field Border Hover
--unity-colors-object_field-border-hover
The border color for an object field control when the mouse pointer hovers over it
Object Field Button Background
--unity-colors-object_field_button-background
The background color for the button in an object field control
Object Field Button Background Hover
--unity-colors-object_field_button-background-hover
The background color for the button in an object field control when the mouse pointer hovers over it
For more information go to Object Fields ->
Slider Colors
Basic and Min / Max slider in dark theme.
--unity-colors-slider_groove-background
The background color for a slider's groove (background)
Slider Groove Background Disabled
--unity-colors-slider_groove-background-disabled
The background color for a slider's groove when it is disabled
--unity-colors-slider_thumb-background
The background color for a slider's thumb/handle
Slider Thumb Background Disabled
--unity-colors-slider_thumb-background-disabled
The background color for a slider's thumb/handle when it is disabled
Slider Thumb Background Hover
--unity-colors-slider_thumb-background-hover
The background color for a slider's thumb/handle when the mouse pointer hovers over it
--unity-colors-slider_thumb-border
The border color for a slider's thumb
Slider Thumb Border Disabled
--unity-colors-slider_thumb-border-disabled
The border color for a slider's thumb when it is disabled
Slider Thumb Halo Background
--unity-colors-slider_thumb_halo-background
The background color for a slider's thumb halo
rgba(12, 108, 203, 0.5019608)
rgba(16, 111, 205, 0.5019608)
For more information go to Sliders ->
Tab Colors
--unity-colors-tab-background
The background color for an Editor window tab
--unity-colors-tab-background-checked
The background color for an Editor window tab when it is selected
--unity-colors-tab-background-hover
The background color for an Editor window tab when the mouse pointer hovers over it
--unity-colors-highlight-background
The background color for selected items or selected text
Inspector Backgrounds
Inspector Titlebar Background
--unity-colors-inspector_titlebar-background
The background color for a title bar in an Inspector view
Inspector Titlebar Background Hover
--unity-colors-inspector_titlebar-background-hover
The background color for a title bar in an Inspector view when the mouse pointer hovers over it
--unity-colors-toolbar-background
The background color for a toolbar control
--unity-colors-window-background
The background color for a window
Inspector Borders
Inspector Titlebar Border
--unity-colors-inspector_titlebar-border
The border color for a title bar in an Inspector view
Inspector Titlebar Border Accent
--unity-colors-inspector_titlebar-border_accent
The border accent color for a title bar in an Inspector view
Window Backgrounds
--unity-colors-default-background
The default background color for controls
Highlight Background Inactive
--unity-colors-highlight-background-inactive
The background color for selected items or selected text when the control does not have focus
--unity-colors-highlight-background
The background color for selected items or selected text
Highlight Background Hover
--unity-colors-highlight-background-hover
The background color for line items when the mouse pointer hovers over them
rgba(256, 256, 256, 0.0627451)
Highlight Background Hover Lighter
--unity-colors-highlight-background-hover-lighter
The background color for an item with a line specific background color when the mouse pointer hovers over them
--unity-colors-window-background
The background color for a window
Alternated Rows Background
--unity-colors-alternated_rows-background
The alternate background color for views with alternating row colors
Window Borders
--unity-colors-default-border
The default border color for controls
--unity-colors-toolbar-border
The border color for a toolbar control
--unity-colors-window-border
The border color for a window