API reference
Compact reference for bridge attributes, state, actions, events, collections, built-in state, and Editor menus.
This is the compact reference. For learning-oriented explanations, use the Bridge and Unity integration sections.
Bridge class
[Bridge]
public partial class UIBridge : LoomBridgeBase
{
}
- Must be
partial. - Must inherit
LoomBridgeBase. - Public properties and public
Event<T>properties are state and events by convention. Methods are actions only when tagged[BridgeAction].
Attributes
| Attribute | Use |
|---|---|
[Bridge] | Marks the root bridge class |
[BridgeAction] | Marks a method as a UI-callable action (root or nested DTO) |
[BridgeIgnore] | Keeps a public state/event member off the bridge |
[BridgeName("name")] | Overrides the UI-facing member name |
State
public int Score { get; set; }
public PlayerState Player { get; set; } = new();
Public properties are state. Assigning a property pushes the new value to the UI.
Image state
public Texture2D Thumbnail { get; set; }
public Sprite Icon { get; set; }
public RenderTexture Minimap { get; set; }
Generated TypeScript exposes these as LoomImageSource | null. Render them
with <LoomImage source={bridge.icon} alt="..." />. Image types are supported
in state DTOs and collections, but not in actions or events. Texture2D and Sprite are immutable snapshots; RenderTexture stays live without
reassignment. See Unity image sources.
Actions
[BridgeAction] public void StartGame() {}
[BridgeAction] public PurchaseResult BuyItem(BuyItemRequest request) {}
Methods tagged [BridgeAction] are actions (on the bridge root or a nested state
DTO). Actions can take any number of parameters and may return a value or Task<T>.
The generated TypeScript call always returns a Promise, including for synchronous
C# methods and void actions.
Events
public Event<DamageEvent> TookDamage { get; } = new();
Fire from C#:
TookDamage.Fire(payload);
Listen from the UI:
onEvent('tookDamage', (payload) => {});
Collections
| Type | Behavior |
|---|---|
List<T> / T[] / Dictionary<K,V> | Snapshot; reassign to sync |
ReactiveList<T> / ReactiveMap<K,V> | Granular changes sync as they happen |
UI image exports
| Export | Use |
|---|---|
LoomImage | Renders a Unity-backed or mock image source with ordinary image attributes |
LoomImageSource | Generated opaque TypeScript type for Unity image state |
createMockImageSource(url) | Creates a typed source from a browser URL in mock mode |
Built-in state
Every bridge has read-only loom.* state:
bridge.loom.currentSceneName
bridge.loom.viewportWidth
bridge.loom.viewportHeight
bridge.loom.devicePixelRatio
bridge.loom.bridgeReady
Keyboard navigation
LoomRuntime.KeyboardMode = LoomKeyboardMode.Gameplay; // default HUD behavior
LoomRuntime.KeyboardMode = LoomKeyboardMode.Navigation; // Tab / Shift+Tab traversal
Keyboard events are forwarded rather than consumed. Switch the game’s input action map alongside this property. JavaScript should request mode changes through bridge actions; DOM focus order remains controlled by normal HTML.
Editor menus
| Menu | Use |
|---|---|
Tools > Loom > Setup UI in Current Scene | Adds LoomUI and configures the project’s URP renderers |
Tools > Loom > Sync UI Dependencies | Installs bundled UI packages into the UI app |
Tools > Loom > Regenerate Types | Rewrites generated TypeScript bridge files |
Tools > Loom > Restart Dev Server | Restarts the Vite dev server |
Tools > Loom > Open Browser DevTools | Opens browser DevTools for the live UI |
Tools > Loom > Doctor | Checks the local Loom environment |
Tools > Loom > Build UI for Player | Runs the production UI build |