Show a React HUD
site/media/lessons/scenes2-batch.lesson.ts (4 steps) In vgai, the HUD is React, mounted into the game’s overlay with mountUI. The editor-tutorial
example mounts a Panel of KeyHints (from the shared UI primitives) over the 3D scene.
-
Open a scene with a React HUD. Load
examples/scenes/editor-tutorial.vscn.json.
The scene whose example mounts a HUD. -
Enter play mode —
mountUImounts the React HUD. The example callsmountUI(ctx.uiContainer, <HUD/>)and stores the returned unmount fordispose().
mountUI mounts the React HUD. -
The HUD
PanelandKeyHints overlay the 3D scene. The panel uses the shared primitives (Panel,Button,Toggle,KeyHint). The overlay ispointer-events: noneby default, so clicks fall through to the 3D scene; interactive widgets opt back in toauto.
A Panel of KeyHints over the viewport. -
Stop play mode. Press Stop (or
Escape) — the stored unmount runs.
Recap
New functionality
- Saw a React HUD over the 3D scene
- Recognized the shared UI primitives
New concepts & skills
- mountUI(container, <HUD/>) returns an unmount for dispose()
- The shared primitives (Panel/Button/Toggle/KeyHint/StatusDot) are inline-styled
- The overlay is pointer-events:none; interactive widgets opt in to auto
Next lesson → Manual: React HUD
On Your Own!
Extend what you built:
- Add a Button to the HUD and wire an onClick
- Set pointer-events:auto on a widget and confirm clicks no longer fall through
- Author a HUD visually with the Visual UI Editor instead