Test in Play
A one-click workflow that loads a pre-baked s&box scene with a controllable TPS player and mounts your UI as a ScreenPanel overlay — so you can see your UI under real Play-mode lifecycle, not the simulated lifecycle of the embedded Preview tab.
Table of contents
- When to use it
- How it works
- Step by step
- The preview stage scene
- When something goes wrong
- Known limitations
- Next
When to use it
- ✅ Final validation before shipping a UI — does it look right at 1920×1080? Does it scale with the player’s camera? Does anything in your
PanelComponentOnUpdateactually run? - ✅ Testing input — buttons, hover, keyboard shortcuts. Embedded preview can’t do this.
- ✅ Testing networking / runtime data —
Game.IsPlayingis true, your bindings can pull real values. - ❌ Quick iteration — Test in Play takes ~3 seconds to spin up the scene and enter Play. For per-property tweaking, use the inline Preview tab instead.
How it works
- SUI Designer compiles your
.suito a sandbox path:<projectRoot>/Code/_sui_preview/<ClassName>/<ClassName>.razor(+.scss). - The engine hot-reloads — your
PanelComponenttype is now inTypeLibrary. - The launcher polls
TypeLibraryfor the new type (up to ~6s). - Once found, it sets a process-local hand-off
SuiPreviewState.PendingTypeFullName = "Game.UI.SuiPreview.<ClassName>". - It opens the bundled scene
Libraries/kikozl.sbox_ui_designer/Assets/sui_preview/preview_stage.scene. - It calls
EditorScene.Play(SceneEditorSession.Active)— the engine enters real Play mode. - The scene’s SUI Preview Mount GameObject’s
OnAwakereadsPendingTypeFullName, creates aScreenPanelhost as its child, and mounts yourPanelComponenton it. - You see the player walking around, with your UI overlaid as
ScreenPanel.
Step by step
1. Click “Test in Play”
In the top toolbar, click the ▶ Test in Play button.
You’ll see logs in the engine console:
[SuiPreviewLauncher] Compiled 'Game.UI.SuiPreview.MyHud'
[SuiPreviewLauncher] Type loaded: Game.UI.SuiPreview.MyHud
[SuiPreviewLauncher] Opened preview stage scene.
[SuiPreviewMount] Mounted 'Game.UI.SuiPreview.MyHud' on ScreenPanel.
[SuiPreviewLauncher] EditorScene.Play() invoked. UI should mount in OnAwake of SuiPreviewMount.
2. The engine enters Play
The Scene Viewport switches from edit mode to play. A Citizen player spawns. Your UI overlays the player view.
WASD moves, mouse rotates the camera. You’re in a real game session.
3. Stop play to return
Click the engine’s Stop button. The scene viewport returns to edit mode on the preview stage scene.
To go back to your original scene, open it manually from the Asset Browser (the launcher does not auto-restore — see workflow notes).
The preview stage scene
Bundled at Libraries/kikozl.sbox_ui_designer/Assets/sui_preview/preview_stage.scene. Contains:
- A 50×50 ground cube
- A directional light (sun)
- An ambient light
- A 2D skybox
- A Citizen
PlayerControllerwith all standard movement components - An empty SUI Preview Mount GameObject —
SuiPreviewMountcomponent readsSuiPreviewStateonOnAwakeand mounts your UI
You can edit this scene if you want a different stage. Save it back to its original path — the launcher always opens this fixed file.
When something goes wrong
If you click Test in Play and nothing happens:
- Open the engine console (
View → Console). Look for[SuiPreviewLauncher]lines. "Preview stage not found at 'sui_preview/preview_stage.scene'"→ library install broken; check installation."Timed out waiting for type … to compile"→ check the console for SCSS or Razor compile errors. The generator emitted invalid code or the engine rejected the SCSS."Already in Play"→ there’s an active play session; press Stop first.
If Play starts but the UI doesn’t appear:
- Look for
[SuiPreviewMount] Mounted …log. If missing, theMountcomponent never ran (scene didn’t load correctly). - If you see the log but no UI, the
PanelComponentmay have failed to construct — check console for runtime exceptions. - Width / Height on the root may be 0 — open the
.sui, check the Canvas section in Details.
Known limitations
- Switches scene context. Your previous scene is closed (asks to save if dirty). When you Stop, you stay on
preview_stage.scene. - One Play at a time. s&box doesn’t support multiple play sessions; if you’re already in Play, the launcher refuses.
- No window minimize / restore. SUI Designer stays where you left it; you may need to bring the Scene Viewport tab to focus manually.
Next
- Editor tour — every panel explained
- Compile + output — what gets written and where
- Workflows · Test in Play — deeper dive on the workflow itself