Panel Renderer component
Create a Panel Renderer component to connect the UI to the panel.
읽는 시간 3분최근 업데이트: 하루 전
A Panel Renderer component references a UXML document and a Panel Settings asset. It serves as a bridge between the Scene and a UXML document. The UXML document specifies the UI structure, while the Panel Settings asset handles rendering.
Create a Panel Renderer component
To create a Panel Renderer component, from the menu, do one of the following:
- To add a Panel Renderer component to an existing GameObject in your scene, select Component > UI Toolkit > Panel Renderer.
- To create a new GameObject with a preconfigured Panel Renderer component, select > UI Toolkit > Panel Renderer.GameObject
?
Connect the UI to a panel
To Connect the UI to a panel, in the window of the Panel Renderer component, configure Panel Renderer component.
Inspector
?

Panel Renderer component
- Panel Settings: The Panel Settings asset that renders the UI.
- Source Asset: The UXML document that contains the UI to display.
- Sort Order: The rendering order of the Panel Renderer component. The lower the value, the earlier the Panel Renderer component renders. For more information about rendering order, refer to Render multiple UXML Documents on the same panel.
- World-Space Dimensions: If you enabled World Space rendering mode, specify the dimensions of the UI in World Space. For more information about World Space rendering, refer to Create a World Space UI.
Render multiple UXML Documents on the same panel
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. To avoid unpredictable rendering, assign unique Sort Order values for siblings when precise layering is important.
Lifecycle of Panel Renderer components
Panel Renderer is a native renderer component that connects UI Toolkit visual elements to Unity's GameObject rendering pipeline. Its lifecycle follows standard Unity component behavior but with specialized UI management.
Unity initializes a Panel Renderer's visual tree when the component is created, when its or properties change, or when the component is enabled. The visual tree is constructed and attached to the GameObject's hierarchy, and any registered delegates are invoked. UI Toolkit calls the during the initial setup of the UI, and anytime the changes. Use to safely interact with UI elements after the visual tree loads:
PanelSettingsVisualTreeAssetVersionedUIReloadCallbackVersionedUIReloadCallbackVisualTreeAssetRegisterUIReloadCallbackvoid OnEnable(){ panelRenderer.RegisterUIReloadCallback(OnUIReload);}void OnDisable(){ panelRenderer.UnregisterUIReloadCallback(OnUIReload);}void OnUIReload(PanelRenderer renderer, VisualElement rootElement, int version){ // 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 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.
VersionedUIReloadCallbackWhen you enable the Panel Renderer component, Unity initializes the UI and adds its visual elements to the visual tree. When you disable it, Unity removes its visual elements from the hierarchy and cleans up resources.