01 / Quick Start
Open the starter and press Play.
First import creates a small project-owned starter, editable React source, and matching built overlay. The onboarding window opens after setup.
- 1
Open Starter Scene
Open Assets/ReLayerUser/Scenes/ReLayer_Starter.unity from the onboarding window.
- 2
Press Play
The default Auto source starts managed Vite development and HMR for the project-owned template.
- 3
Edit the app
Change Assets/ReLayerUser/Overlay/Template/src/App.tsx and src/styles.css.
- 4
Build normally
Unity player builds refresh the production overlay before writing the player.
Toolchain
Use Unity 2022.3 or newer. Node.js is needed only when editing or rebuilding the overlay: use Node.js ^20.19.0 or ≥22.12.0. Node.js 21 and 22.0–22.11 do not meet the packaged Vite runtime contract.
02 / Ownership
Keep custom UI outside the imported package.
ReLayer separates imported package code, buyer-owned source, generated production output, and isolated working files. Asset Store reimports update the package while preserving your app.
| Path | Owner | Purpose |
|---|---|---|
| Assets/ReLayer | Package | Runtime, editor integration, samples, and reusable kits |
| Assets/ReLayerUser/Overlay/Template | Your project | Editable React/Vite application source |
| Assets/StreamingAssets/ReLayer/overlay | Generated | Current production output for user scenes |
| .relayer/profiles/default/OverlayTemplate | ReLayer work copy | Isolated dependencies, dev server, and builds |
Do not run npm install inside the Unity template folder. ReLayer installs dependencies in its isolated work copy so Unity never imports node_modules.
03 / Editor
Choose the right Play Mode source.
Default
Auto
Prewarms managed Vite/HMR for the standard user source. Rebuilds and falls back to verified production output if live startup is unavailable.
Explicit live
LiveDevServer
Requires the managed Vite development path and is useful when live iteration must be enforced.
Production view
BuiltOverlay
Loads the StreamingAssets output after checking it against the active source fingerprint.
After installing Node.js or changing the toolchain, set RELAYER_NPM_PATH when needed, then choose Tools/ReLayer/Restart Overlay Session.
04 / Live Twin
Control the authoritative Play Mode DOM from a browser.
Choose Tools/ReLayer/Live Twin/Open. ReLayer opens a tokenized loopback page that mirrors the actual WebView owned by Unity; it does not run a second React app or add another bridge client.
const status = await window.__RELAYER_LIVE_TWIN_V1__.getStatus()
await window.__RELAYER_LIVE_TWIN_V1__.click(mirrorElement)
await window.__RELAYER_LIVE_TWIN_V1__.setValue(mirrorInput, "Pilot")Live Twin dispatches synthetic DOM events. Trusted-event and browser-activation workflows are unsupported. File input, clipboard permission, fullscreen, payments, downloads, external navigation, new windows, and arbitrary JavaScript are blocked.
05 / Bridge
Send named events in both directions.
Unity remains authoritative for game state. React renders UI and sends explicit actions back. Mark interactive React surfaces with data-relayer-hit so transparent areas keep normal Unity input.
Unity → React
ReLayerBridgeManager.GetOrCreate().Send(
ReLayerBridgeEventType.UnityToUiToast,
new ReLayerToastPayload
{
title = "Unity event received",
body = "Sent from Unity."
});React → Unity
<button
data-relayer-hit
onClick={() => bridge.send('UI_ACTION', { action: 'pause' })}
>
Pause
</button>Use hasUnityRuntimeConnection() for Play-only loading gates and state requests. A native WebView callback alone can also exist for an Edit Mode visual preview.
06 / Kits
Reuse package-owned components without giving up your app.
New templates import maintained kits through the stable #relayer/* namespace. Package updates can improve those kits while your application and styles remain in Assets/ReLayerUser.
import { Button, Card, TextField } from '#relayer/components'
import { GlassButton, GlassPanel, GlassRoot } from '#relayer/glass'
import { getComponentTheme } from '#relayer/themes'
const theme = getComponentTheme('edge')Create a project-owned fork only when you need to edit kit internals. Forked files stay yours and are not updated by later package imports.
07 / Platforms
Use the exact first-party runtime matrix.
| Target | Backend | Supported runtime |
|---|---|---|
| Windows Editor and Player | WebView2 | Windows x86_64 only; Edge WebView2 Runtime required |
| macOS Editor and Player | WKWebView | Apple Silicon arm64, macOS 11+ |
| iOS device | WKWebView XCFramework | arm64 devices, iOS 12+ |
| iOS Simulator | WKWebView XCFramework | arm64 Simulator on Apple Silicon, iOS 14+ |
| Android Player | Android WebView | API level 21+; arm64-v8a and x86_64 |
| WebGL Player | Same-document DOM layer | Browser backend; no native plug-in |
| Linux | None | No bundled first-party backend |
08 / WebGL
Serve the player and overlay over HTTPS.
WebGL imports the overlay into a ReLayer-owned DOM layer aligned with the Unity canvas. Keep the player page, Build files, and StreamingAssets/ReLayer content on the same origin when possible.
- Production requires HTTPS; file:// is unsupported and plain HTTP is loopback-development only.
- Split origins need CORS for overlay HTML, modules, CSS, fonts, images, and media.
- CSP must allow Unity/WASM plus ReLayer connections, styles, assets, and blob: module URLs.
- Use a CSP nonce ReLayer can copy, or explicitly allow the required inline import maps and scoped styles.
| Suffix | Content-Type | Content-Encoding |
|---|---|---|
| .js.gz | application/javascript | gzip |
| .wasm.gz | application/wasm | gzip |
| .data.gz | application/octet-stream | gzip |
09 / Build
Let Unity keep the production overlay current.
Player builds rebuild the active overlay before the Unity build starts, regardless of the Editor Play Mode source. Use the manual helper only when you intentionally need production output outside a player build.
Assets/ReLayer/Core/Build/build-overlay.ps1
# Optional: omit bundled example themes
Assets/ReLayer/Core/Build/build-overlay.ps1 -ExcludeExampleThemesThe packaged Showcase is isolated at Assets/StreamingAssets/ReLayer/showcase. User scenes load the project output at Assets/StreamingAssets/ReLayer/overlay.
Need the complete reference?
Download the packaged 1.1.1 guide for detailed API contracts, Asset Broker, Camera Render Broker, safe-area handling, third-party integration, and dependency notices.