DTO rules
DTOs are plain C# types used as nested state, action parameters, action return values, or event payloads.
Supported shape
Use simple public properties:
public sealed class InventoryItem
{
public string Id { get; set; } = "";
public string Name { get; set; } = "";
public int Count { get; set; }
} Prefer:
string,bool, numeric types- enums
- DTO classes and structs
- arrays and lists
- dictionaries with supported key and value types
Avoid exposing Unity engine objects, services, delegates, file handles, or runtime-only references across the bridge.
Naming
C# names are converted to camelCase in TypeScript:
public int CurrentHealth { get; set; } bridge.currentHealth; Use [BridgeName] only when you must preserve a different UI-facing name.
Enums
Enums appear in TypeScript as string values:
public enum Screen
{
MainMenu,
Hud
} type Screen = 'MainMenu' | 'Hud'; Nulls
Prefer initialized values for state DTOs and collections. Nulls are harder for UI code to work with and can hide missing initialization during startup.
Regenerate after changes
Run:
Loom -> Regenerate Types after changing DTO fields, enum values, action signatures, or event payloads.