Reference API reference
Reference

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

C#
[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

AttributeUse
[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

C#
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

C#
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

C#
[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

C#
public Event<DamageEvent> TookDamage { get; } = new();

Fire from C#:

C#
TookDamage.Fire(payload);

Listen from the UI:

TSX
onEvent('tookDamage', (payload) => {});

Collections

TypeBehavior
List<T> / T[] / Dictionary<K,V>Snapshot; reassign to sync
ReactiveList<T> / ReactiveMap<K,V>Granular changes sync as they happen

UI image exports

ExportUse
LoomImageRenders a Unity-backed or mock image source with ordinary image attributes
LoomImageSourceGenerated 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:

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

Keyboard navigation

C#
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

MenuUse
Tools > Loom > Setup UI in Current SceneAdds LoomUI and configures the project’s URP renderers
Tools > Loom > Sync UI DependenciesInstalls bundled UI packages into the UI app
Tools > Loom > Regenerate TypesRewrites generated TypeScript bridge files
Tools > Loom > Restart Dev ServerRestarts the Vite dev server
Tools > Loom > Open Browser DevToolsOpens browser DevTools for the live UI
Tools > Loom > DoctorChecks the local Loom environment
Tools > Loom > Build UI for PlayerRuns the production UI build
Loom documentation

Search docs

Esc

Type a word or phrase to search the documentation.

Type a word or phrase to search the documentation.