# UI Toolkit and Diegetic UI in Unity 6
> [!important] Version requirement
> This tutorial targets **Unity 6000.5 and newer**. It uses the `PanelRenderer` component (6000.5+), World Space UI Toolkit panels (first shipped in 6.2), runtime data binding (Unity 6.0+), and `[UxmlElement]` custom controls. Older Unity 6 streams (6000.0 - 6000.4) still have `UIDocument`; see the callout in [[2.UI Toolkit Project Setup]] for the one-to-one swap.
> [!warning] Verification status
> The APIs and menu paths were checked against the Unity 6000.3 / 6000.5 / 6000.7 documentation while writing. The C# in these notes was **not compiled in an editor** by the author. Expect to fix an odd using or a renamed enum on first paste, and check the Console before assuming a conceptual problem.
This tutorial assumes you are an experienced Unity developer. It skips "what is a GameObject" and goes straight to how UI Toolkit works at runtime, how to structure a real HUD and inventory with it, and how to put UI *inside* the game world (diegetic UI) in three different ways.
## Reading order
1. **[[1.UI Toolkit Concepts]]** - the mental model: visual tree, UXML, USS, panels, events, queries, layout.
2. **[[2.UI Toolkit Project Setup]]** - Panel Settings, `PanelRenderer` (and `UIDocument`), folder layout, theme, scaling, input.
3. **[[3.HUD and Inventory Example]]** - a full worked example: HUD with data-bound health bar and toasts, plus an inventory screen with a `ListView`. Complete UXML + USS + C#.
4. **[[4.Data Binding and Custom Controls]]** - runtime binding in depth, converters, change notification, and a bindable `[UxmlElement]` control.
5. **[[5.Diegetic UI Approaches]]** - what diegetic UI is, and the three implementation routes with a decision table.
6. **[[6.Diegetic Terminal and Wrist Display]]** - an interactive in-world terminal (UI Toolkit on a RenderTexture with ray-to-UV input) and a world-space wrist display (World Space `PanelRenderer`).
7. **[[7.UI Toolkit Pitfalls and Performance]]** - the failure modes you will actually hit, and performance rules.
8. **[[8.UI Toolkit for VR]]** - world-space UI Toolkit panels in VR: how XR Interaction Toolkit ray and poke interactors drive them, setup checklist, diagnostics script, and a RenderTexture ray-to-UV fallback. Applied in [[7.Quest 2 Worked Example Room]] (see [[Meta Quest 2]]).
## What you will build
| Piece | Technique | Note |
|---|---|---|
| Screen HUD (health bar, gold, toast, hint) | `PanelRenderer`, USS variables, runtime data binding | [[3.HUD and Inventory Example]] |
| Inventory screen | Separate UXML on a sibling panel, `ListView`, `ScriptableObject` items, USS transitions | [[3.HUD and Inventory Example]] |
| Reusable resource bar | `[UxmlElement]` custom control with bindable properties | [[4.Data Binding and Custom Controls]] |
| Wall / desk terminal | UI Toolkit -> `RenderTexture` -> mesh, `SetScreenToPanelSpaceFunction` | [[6.Diegetic Terminal and Wrist Display]] |
| Wrist display | Panel Settings in World Space, Panel Input Configuration | [[6.Diegetic Terminal and Wrist Display]] |
| VR control panel (ray and poke) | World Space panel + XRUIToolkitManager + XRI interactors; RenderTexture fallback | [[8.UI Toolkit for VR]] |
## Official documentation (start here when something differs)
- UI Toolkit manual: https://docs.unity3d.com/6000.5/Documentation/Manual/UIElements.html
- Panel Renderer component: https://docs.unity3d.com/6000.5/Documentation/Manual/ui-systems/panel-renderer-component.html
- `PanelRenderer` API: https://docs.unity3d.com/6000.5/Documentation/ScriptReference/UIElements.PanelRenderer.html
- World Space UI: https://docs.unity3d.com/6000.3/Documentation/Manual/ui-systems/world-space-ui.html
- Create a World Space UI: https://docs.unity.com/en-us/engine/6000.3/manual/uitoolkits/uielements/uie-support-for-runtime-ui/world-space-ui/create
- Panel Input Configuration properties: https://docs.unity.com/en-us/engine/6000.3/manual/uitoolkits/uielements/uie-support-for-runtime-ui/world-space-ui/panel-input-configuration
- `PanelSettings.targetTexture`: https://docs.unity3d.com/6000.3/Documentation/ScriptReference/UIElements.PanelSettings-targetTexture.html
- `PanelSettings.SetScreenToPanelSpaceFunction`: https://docs.unity.com/en-us/engine/6000.7/script-reference/unityengine/uielements/panelsettings/setscreentopanelspacefunction
- Runtime data binding (define a data source): https://docs.unity3d.com/6000.2/Documentation/Manual/UIE-runtime-binding-define-data-source.html
- Runtime binding in C#: https://docs.unity3d.com/Manual/UIE-runtime-binding-types.html
- Create a custom control: https://docs.unity3d.com/6000.3/Documentation/Manual/UIE-create-custom-controls.html
- Customize UXML attributes: https://docs.unity3d.com/Manual/ui-systems/custom-control-customize-uxml-attributes.html
- UI Toolkit status (Unity forum, Nov 2025): https://discussions.unity.com/t/ui-toolkit-development-status-and-next-milestones-november-2025/1698009
- PanelRenderer announcement (Unity forum): https://discussions.unity.com/t/panelrenderer-evolution-of-the-uidocument-component-in-6-5/1715909
- XR Interaction Toolkit + UI Toolkit (world-space UI in VR): https://docs.unity3d.com/Packages/
[email protected]/manual/ui-world-space-ui-toolkit-support.html
## See also
- For EventSystem / Input System UI Input Module wiring: [[Input System]].
- Localizing labels with UI Toolkit data bindings (`SetBinding("text", LocalizedString)`): [[Localization]].
See also (added 2026-11-10): [[Context-Sensitive Prompts and Onboarding]] / [[3. Glyph Prompts in UI Toolkit]] - PanelRenderer prompt HUD with a text fallback when a glyph is missing.