ReLayer documentation

From first import to a production overlay.

Follow the shortest working path, then use the focused guides for Live Twin, bridge events, platform requirements, and WebGL hosting.

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. 1

    Open Starter Scene

    Open Assets/ReLayerUser/Scenes/ReLayer_Starter.unity from the onboarding window.

  2. 2

    Press Play

    The default Auto source starts managed Vite development and HMR for the project-owned template.

  3. 3

    Edit the app

    Change Assets/ReLayerUser/Overlay/Template/src/App.tsx and src/styles.css.

  4. 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.

PathOwnerPurpose
Assets/ReLayerPackageRuntime, editor integration, samples, and reusable kits
Assets/ReLayerUser/Overlay/TemplateYour projectEditable React/Vite application source
Assets/StreamingAssets/ReLayer/overlayGeneratedCurrent production output for user scenes
.relayer/profiles/default/OverlayTemplateReLayer work copyIsolated 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.

Click, focus, blur, type, select, scroll, use keyboard and pointer actions, hover, drag, and submit forms
Ordered control from up to eight browser tabs with the latest authoritative result applied to every twin
Source-aware element metadata during Vite development when React debug evidence is available
DOM commands continue while Play Mode is paused; Unity game work may wait until resume
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.

TargetBackendSupported runtime
Windows Editor and PlayerWebView2Windows x86_64 only; Edge WebView2 Runtime required
macOS Editor and PlayerWKWebViewApple Silicon arm64, macOS 11+
iOS deviceWKWebView XCFrameworkarm64 devices, iOS 12+
iOS SimulatorWKWebView XCFrameworkarm64 Simulator on Apple Silicon, iOS 14+
Android PlayerAndroid WebViewAPI level 21+; arm64-v8a and x86_64
WebGL PlayerSame-document DOM layerBrowser backend; no native plug-in
LinuxNoneNo 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.
SuffixContent-TypeContent-Encoding
.js.gzapplication/javascriptgzip
.wasm.gzapplication/wasmgzip
.data.gzapplication/octet-streamgzip

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 -ExcludeExampleThemes

The 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.