UI Builder
UI Builder lets you visually create and edit UI using UIElements, UXML, and USS.
Feature List
Global
- Can delete element via Delete key.
- Can cut/copy/duplicate/paste element via hot key, with the copied element (and all its children) being pasted as a child to the the parent of the currently selected element (or root if nothing is selected).
- Can cut/copy/duplicate/paste Template instances, adding the correct Template registrations to the file.
- Can copy/paste elements to and from a text file as valid UXML.
- Can undo/redo style changes, hierarchy changes, and selection changes.
- Open documents, current selection, and unsaved changes will survive domain reload.
- Double-clicking a .uxml asset in the Project will open it using the UI Builder.
Explorer
StyleSheet
- Can select the main StyleSheet by the "StyleSheet" Explorer item, showing its dedicated Inspector.
- Selectors with .classNames get pills for each class created in the Explorer.
- In the Explorer, you can select selectors by clicking on the row or a class pill.
- Can drag a style class pill from the Explorer onto an element in the Viewport to add the class.
- Can drag a style class pill from the Explorer onto an element in the Hierarchy to add the class.
- Dragging a style class onto an element inside a template instance or C# type in the Viewport adds it to the parent instance or C# element.
- Dragging a style class onto an element inside a template instance or C# type in the Hierarchy does nothing.
- Below all selectors there's a field that lets you create new selectors (by pressing enter).
- If Class mode is selected, a new
.class
selector will be added and you have options for the pseudo states to add. - If Complex mode selected, the raw string will be used for the full selector name, and the pseudo stats MaskField should not be visible.
- If Class mode is selected, a new
- When hovering or selecting a style selector in the Explorer, all elements in the Canvas that match this selector will highlight.
- With a selector selected, you can use the standard short-cuts and Edit menu to copy/paste/duplicate/delete it. You can also copy/paste the USS for the selector to/from a text file.
- Right-clicking anywhere in the Hierarchy will open the Copy/Paste/Duplicate/Delete context menu.
Hierarchy
- Can click to select element.
- Can drag element onto other elements in the Hierarchy to reparent.
- Can drag element between other elements to reorder, with live preview in the Canvas.
- Can drag element onto other elements in the Viewport to reparent.
- Elements are displayed using their #name in blue, or C# type in white if they have no name.
- Elements are displayed grayed out if they are children of a template instance or C# type.
- Selecting an element inside a template instance or C# type will display the Inspector in read-only (disabled) mode.
- Dragging element onto a template instance or C# type element in the Viewport reparents it to the parent instance or C# element.
- Dragging element onto a template instance or C# type element in the Hierarchy does nothing.
- With an element selected, you can use the standard short-cuts and Edit menu to copy/paste/duplicate/delete it. You can also copy/paste the UXML for the element to/from a text file.
- Right-clicking anywhere in the Hierarchy will open the Copy/Paste/Duplicate/Delete/Rename context menu.
- Can double-click on an item to rename it.
Library
- Displays built-in elements under a Unity heading.
- Displays project defined factory elements and UXML files (with .uxml extension) under a Project heading. This includes assets inside both the
Assets/
andPackages/
folders. - Can double click to create new element instance in the root.
- Items that have corresponding .uxml assets will have an "Open" button visible that will open the asset for editing in the UI Builder. The currently open .uxml asset in the Library will be grayed out and will not be instantiable to prevent infinite recursion.
- Can click-drag onto a Viewport element to create new instance as a child.
- Can click-drag onto a Hierarchy element to create new instance as a child, or between elements to create as a sibling.
- Can create (double-click or drag) template instances from other uxml files.
- When creating a new empty VisualElement, it will have an artificial minimum size and border which will be reset as soon as you parent a child element under it or change its styling.
- Hovering over items in the Library will show a preview of that element in a floating preview box. The preview will use the current Theme selected for the canvas.
- Library pane will update if new uxml files are added/deleted/move/renamed to/from the project.
Viewport
Toolbar
- Pressing New will clear the selection, the Viewport canvas, the Explorer, and all undo/redo stack operations for the previous document. A prompt will be displayed if there are unsaved changes.
- Pressing Save will ask for new file names for USS and UXML if it is the first save, otherwise, it will overwrite the previously saved/loaded files.
- Saving should work even if the openend assets have been moved or renamed (in which case, the Builder should update the USS Style paths inside the UXML document).
- Pressing Save As will always ask for a new file name and save as a copy of the current document.
- Dragging a .uxml asset onto the Object Field will load that file.
- Can preview Light/Dark theme inside the canvas via the Theme popup field, independent from the current Editor Theme. Default Theme will use the current Editor Theme, while the other options will force a theme to be used in the canvas.
- Pressing Game will change the background of the canvas to a render texture of the main camera in the Scene. This will render the camera view in real time.
- Pressing Preview will toggle Preview Mode where you can no longer select elements by clicking on them in the Viewport, but instead, Viewport elements recieve regular mouse and focus events.
Save Dialog
- Entering paths that do not start with "Assets/" or "Packages/" will show an invalid path message and the Save button will be disabled.
- Updating the UXML Path field will automatically update the USS Path field to match, until the USS Path field is changed manually.
- Entering file names without extensions will still add the correct extensions when creating the assets.
- The "..." button beside each path field should bring up the system Save File Dialog.
- Folders in an otherwise valid path will be created if missing.
Canvas
- Can click to select element.
- Selecting an element inside a template instance or C# type selects the parent instance or C# element.
- Relative position elements have bottom, right, and bottom-right handles that change inline
height
andwidth
styles. - Absolute position elements have all 4 side and 4 corner handles visible.
- Absolute position elements have 4 anchor handles visible to set or unset the
left
/right
/top
/bottom
inline styles. - Absolute position elements can be click-drag moved, changing
top
/right
/left
/bottom
inline styles depending on anchor state. - Resize and position handles change different styles depeneding on anchor state (ie. if
left
andright
styles are set, changing the width changes theright
style - otherwise, changing the width changes thewidth
style). - Canvas size will be restored after Domain Reload or Window reload. It will be reset when opening a new document.
- When changing Width or Height in the Inspector, the corresponding resize handles in the canvas will highlight.
- When hovering over elements in the Canvas, the corresponding entry in the Hierarchy will highlight.
- When hovering over elements in the Canvas, all Explorer entries of style selectors that match this element will highlight.
- If the Canvas is bigger than the Viewport, a Fit Canvas button will appear that will resize the Canavs to fit in the Viewport.
Previews
UXML
- Updates text on any hierarchy, attribute, or inline style changes.
- Shows unsaved StyleSheet as path="*unsaved in-memory StyleSheet with...".
- Upon saving, all unsaved StyleSheet paths are fixed.
- Shows
<Style>
tags for all root elements. - (2019.3+) A relative path to a
.uss
asset will be used in thesrc
attribute of the<Style>
tag if the asset is in the same folder (directly or in a subfolder) as the main asset. Otherwise, an absolute path will be used. - (2019.3+) A relative path to a
.uxml
asset will be used in thesrc
attribute of the<Template>
tag if the asset is in the same folder (directly or in a subfolder) as the main asset. Otherwise, an absolute path will be used.
USS
- Updates on all StyleSheet/Selector changes.
- Dimension (Length) styles have the unit added to the USS (
px
). (No support for%
yet.)
Inspector
StyleSheet Section
- Only visible if the selection is a StyleSheet (by selecting the Shared Styles section header in the Explorer).
- Can create new Selectors by entering text in the Selector field and pressing Enter (or the Create button).
- Shows quick help on selectors.
Style Selector Section
- Only visible if the selection is a selector in the current StyleSheet.
- Can change the selector text by changing the Selector field and pressing Enter.
Attributes Section
- Only visible if the selection is an element in the current document.
- Shows all valid attributes for the selected element, given its C# type.
- Attribtues already set to a non-default value are highlighted with the same styling as Prefab overrides.
- Changing attributes updates the Explorer, the Viewport, and the UXML Preview and changes are immediate.
- Right-click Unset on an attribute will remove it from the UXML tag, reset the value to the element-defined default, and reset the override styling.
Inherited Styles Section
- Only visible if the selection is an element in the current document.
- Can add existing style class to element by typing the name of the class in the field inside Inherited Styles and pressing the Add Style Class to List button (or pressing Enter).
- Can extract all overwritten Local Styles to a new style class by typing the name of the class in the field inside Inherited Styles and pressing the Extract Local Styles to New Class button.
- If the style class being added to an element is not valid, an error message will appear.
- All style classes on the current element are displayed as pills.
- Style class pills have an X button that lets you remove them from the element.
- Under Matching Selectors, all matching selectors on the current element are displayed with read-only fields for their properties.
Local Styles
- Only visible if the selection is an element in the current document, or a selector in the current StyleSheet.
- Changing any value will set it in the StyleSheet or inline UXML style attribute and highlight it with a solid bar on the left side and bold font.
- Style category headers will have an override bar and bold font if any child styles are overridden.
- All style value types are supported.
- Sub-section foldout expanded states are preserved between selection changes and domain reload.
- Right-click Unset on an style field will remove it from the UXML inline style or StyleSheet, reset the value to default, and reset the override styling.
- Align section toggle button strips will change icons depending on the value of the flex-direction style.