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
Shared Styles
- Can select the main StyleSheet by the Shared Styles header, 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.
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 selects the parent instance or C# element.
- 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.
- Right-clicking anywhere in the Hierarchy will open the Copy/Paste/Duplicate/Delete context menu.
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.
- 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.
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.
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.
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.
Shared Styles Section
- Only visible if the selection is an element in the current document.
- Can add new class to element by typing in the Add Style Class: field and pressing the Add Style Class: (or pressing Enter).
- 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 Style Overrides
- 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 the same styling as Prefab overrides.
- 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.