Connecting Unity and UI Built-in Loom state
Connecting Unity and UI

Built-in Loom state

Read the loom.* state Loom maintains on every bridge.

Every bridge includes a small loom state object maintained by Loom. You do not declare it yourself.

TSX
const bridge = useBridge();

bridge.loom.currentSceneName;
bridge.loom.viewportWidth;
bridge.loom.viewportHeight;
bridge.loom.devicePixelRatio;
bridge.loom.bridgeReady;

Fields

FieldTypeMeaning
currentSceneNamestringThe active Unity scene name
viewportWidthnumberCurrent UI viewport width in CSS pixels
viewportHeightnumberCurrent UI viewport height in CSS pixels
devicePixelRationumberCurrent device pixel ratio
bridgeReadybooleanWhether the bridge has completed startup

Usage

Use built-in state for responsive UI and connection-aware screens:

TSX
const bridge = useBridge();

const compact = () => bridge.loom.viewportWidth < 900;

Ownership

The loom object is read-only from the UI. Loom updates it as the Unity scene, viewport, DPI, and connection state change.

Loom documentation

Search docs

Esc

Type a word or phrase to search the documentation.

Type a word or phrase to search the documentation.