Work with elements in-scene
Add, reorder, and manage visual elements in the scene.
読み終わるまでの所要時間 4 分最終更新 9日前
The basic building block in UI Toolkit is a . Visual elements form a parent-child visual tree. You can add and organize elements directly in the Hierarchy window in the Main Stage, or in UI Staging mode.
VisualElementAdd elements
To add an element to a UXML document:
-
Open the element menu using one of the following methods:
- In the Hierarchy window or in UI Staging mode, select + > UI Toolkit > Standard Element.
- In the main menu, go to > UI Toolkit > Standard Element.GameObject
?
-
Select the element from the list.If the element you want isn't in the list, select UI Library to open the UI Library window, then select the element or drag it directly from the UI Library window to the UXML document.
After you add an element, the Hierarchy window expands to show the new element, selects it, and starts renaming it so you can give it a name. Template instances are selected but not renamed.
Add a child element
To add a child element to a parent:
- Right-click (macOS: Ctrl+click) the parent and select Standard Element > Add Child.
- Select the element from the list.
By default, elements have no Name attribute and appear in the Hierarchy window by type. To name an element, right-click it in the Hierarchy window and select Rename, or set a name in the window. Names identify elements in the UI and don't need to be unique. However, an element must have a name before you can override its attributes in a template instance.
Inspector
?
Reorder elements
To reorder elements, you can drag one or more elements in the hierarchy or move them between parents:

Reorder in hierarchy
Move elements between UI documents
In the Main Stage, you can drag an element from one UI document to another in the Hierarchy window.
Move world space elements in the Scene view
You can use the Move, Rotate, and Scale tools to transform elements in the view. Unity writes the result as inline styles on the element's , , and properties. In the Main Stage, these tools are available for world space UI only.
Scene
?
translaterotatescaleWhen you select a visual element that these tools can transform, the Tools overlay in the Scene view switches to the visual element context and shows the tools available for that element.
Locate and frame elements
To find a UI element in the view, select it in the Hierarchy window and do one of the following:
- Double-click the element.
- Press F, or select Edit > Frame Selected.
- Right-click (macOS: Ctrl+click) the element and select Frame Selection. The context menu shows each action's shortcut.
For world-space UI, you can also press Option+F (macOS) or Alt+F (Windows), or right-click the element and select Frame and Align to View, to frame the panel so the camera faces it head-on.
When you edit in UI Staging, framing an element resolves its world-space instance in the scene automatically.
Use the context menu in the Scene view
To choose from all elements under the pointer, hold Ctrl (macOS: Cmd) and right-click in the Scene view.
Save and rename UXML assets
To save one UXML asset without saving other modified assets, do one of the following:
- In the Hierarchy window, right-click the UXML document and select Save <file_name>.
- In the Inspector window, open the More (⋮) menu and select Save <file_name>.
To rename a UXML asset, rename its node in the Hierarchy window. This renames the file in your project. The GameObject keeps its name.
.uxml.uxmlEdit text in the UI Viewport
For text elements such as Button or Label, you can edit the attribute in the UI Viewport window by double-clicking the control. Press Enter to add a new line. Press Shift + Enter to commit. Press Esc to cancel.
text