Introduction to visual elements and the visual tree
Understand visual elements in the visual tree and how to use it.
読み終わるまでの所要時間 2 分最終更新 1ヶ月前
The most basic building block in UI Toolkit is a visual element. The visual elements are ordered into a hierarchy tree with parent-child relationships. This is called the visual tree.
The diagram below displays a simplified example of the visual tree, and the rendered result in UI Toolkit.

Simplified hierarchy of the visual tree
The Root in the diagram represents the in the Editor UI and the in a runtime UI.
EditorWindow.rootVisualElementUIDocument.rootVisualElementThe class is the base for all nodes in the visual tree. The base class contains properties such as styles, layout data, and event handlers. Visual elements can have children and descendant visual elements. For example, in the diagram above, the first visual element has three child visual elements: , , and .
VisualElementVisualElementBoxLabelCheckboxSliderYou can customize the appearance of visual elements through inline styles and stylesheets. You can also use event callbacks to modify the behavior of a visual element.
VisualElementA control includes the visual of the control, and the scripted logic to operate and interact with the control. It can consist of a single visual element, or a combination of multiple visual elements. For example, the Toggle control contains three elements:
- A text label
- An image of a box
- An image of a checkmark

Toggle control
The implementation of the Toggle control defines the behavior of the control. It has an internal value of whether the toggle state is true or false. This logic alternates the visibility of the checkmark image when the value changes.
You can also combine visual elements together and modify their behavior to create custom controls.
To use a control in a UI, add it to the visual tree.