The bridge model
The bridge is the typed contract between your Unity game and your Solid UI. You define it in C#, and Loom generates the matching TypeScript surface.
There are three concepts:
| Direction | Bridge member | Use it for |
|---|---|---|
| C# to UI | State properties | Values the UI should render reactively |
| UI to C# | [BridgeAction] methods | Buttons, form submits, menu actions |
| C# to UI | Event<T> properties | One-shot notifications |
State
State is data the UI reads:
public int Health { get; set; } = 100; When C# assigns a new value, the UI updates:
const bridge = useBridge();
<span>{bridge.health}</span> Use state for values that have a current truth: selected screen, player health, inventory snapshots, loading progress, current scene, and settings.
Actions
Actions are public C# methods tagged [BridgeAction] that the UI can call:
[BridgeAction]
public void OpenInventory()
{
CurrentScreen = GameScreen.Inventory;
} The UI calls the generated action proxy:
await bridge.openInventory(); Use actions for user intent: click, confirm, purchase, equip, submit, start, cancel.
Events
Events are one-shot messages from C# to UI:
public Event<DamageEvent> TookDamage { get; } = new(); Use events for moments rather than durable state: damage flash, toast, reward burst, alert sound, or animation trigger.
Choosing the right primitive
- If the UI needs to know the latest value, use state.
- If the UI is asking the game to do something, use an action.
- If the game is announcing that something happened, use an event.
The next pages go deeper into each piece.