A Panel Renderer component references a UXML document and a Panel Settings asset. It serves as a bridge between the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary and a UXML document. The UXML document specifies the UI structure, while the Panel Settings asset handles rendering.
To create a Panel Renderer component, do one of the following:
To Connect the UI to a panel, in the InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary window of the Panel Renderer component, configure Panel Renderer component.
A panel can display UI from more than one Panel Renderer component. This allows you to break complex UIs into smaller, more manageable parts. Each Panel Renderer component references a different UXML document and the same Panel Settings asset.
Each Panel Renderer component has a Sort Order property that controls rendering order. The UXML documents are rendered based on their order in the Hierarchy: child Panel Renderer components render on top of their parents. Sibling Panel Renderer components (at the same hierarchy level) render in ascending order based on their Sort Order value. The lower the Sort Order value, the earlier the Panel Renderer component renders.
Note: If there are multiple Panel Renderer components attached to the same Panel Settings, all these Panel Renderer components share a common focus navigation context. If they have distinct Panel Settings, navigation won’t jump automatically from one to the other even if you arrange them side by side. To make navigation jump from one to the other, you must set the focusController of the Panel Settings to the FocusController of the Panel Renderer component you want to jump to.
Panel Renderer is a native Renderer component that connects UI Toolkit visual elementsA node of a visual tree that instantiates or derives from the C# VisualElement class. You can style the look, define the behaviour, and display it on screen as part of the UI. More info
See in Glossary to Unity’s GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary rendering pipeline. Its lifecycle follows standard Unity component behavior but with specialized UI management.
Unity initializes a Panel Renderer’s visual treeAn object graph, made of lightweight nodes, that holds all the elements in a window or panel. It defines every UI you build with the UI Toolkit.
See in Glossary when the component is created, when its PanelSettings or VisualTreeAsset properties change, or when the component is enabled. The visual tree is constructed and attached to the GameObject’s hierarchy, and any registered UIReloadCallback delegates are invoked. Use RegisterUIReloadCallback to safely interact with UI elements after the visual tree loads:
void OnEnable()
{
panelRenderer.RegisterUIReloadCallback(OnUIReload);
}
void OnDisable()
{
panelRenderer.UnregisterUIReloadCallback(OnUIReload);
}
void OnUIReload(PanelRenderer renderer, VisualElement rootElement)
{
// Your UI initialization logic.
}
If you assign or change the PanelSettings or VisualTreeAsset properties, the Panel Renderer marks itself as dirty and reloads the UI. This triggers the UIReloadCallback again. If the GameObject’s parent changes, or if the PanelRenderer is nested under another Panel Renderer, the component updates its hierarchy and might reparent its root visual element accordingly.
When the component is enabled, it ensures the UI is initialized and added to the visual tree. When disabled, it removes its visual elements from the hierarchy and cleans up resources.