SplitScript reference / Language / class

class

declaration

class Name from ["Alias", ...] { Type field; static Type field; if shape == Variant { ... } }

Declares a typed managed class binding.

The class name T denotes an immutable local snapshot, while T.Ref denotes a live remote object reference. Fields without static are read fallibly from a T.Ref; static fields are read through the class name. Field lookup follows the runtime inheritance chain. For an inherited static field, the provider binds storage through the runtime class that actually declares the field, including a closed generic base, while the source still uses the ergonomic Derived.field spelling. Each live field hop yields T!, so postfix ? can propagate an unsuccessful lookup to the surrounding state field, function, or retry boundary. Calling reference.snapshot() reads every active instance field first and exposes one T! only when the complete snapshot succeeds; no partially populated object escapes when a read fails. Live scalar paths reread remote memory without allocating a GC object, while snapshots and arrays materialize owned values. await T.instances() cooperatively scans readable, writable, non-executable process memory and returns a completed [T.Ref] snapshot. A UnityGameObject obtained through unity.scenes can use component<T>() to find the same typed T.Ref by runtime class. Both traversal paths are bounded, and generated binders, readers, snapshots, and scans are retained only when used. The optional from list supplies runtime metadata names. Fields declared directly in the class are always available. Put build-specific fields in an if / else if / else chain over an enum global initialized during onAttach. When the managed metadata uniquely identifies the enum variant, the Unity provider initializes that global automatically. Each later branch describes exactly the variants left unmatched by earlier branches, and the same predicate refines those fields in ordinary code. Mono and IL2CPP metadata traversal remains private to the Unity provider.

Examples

Follow a typed managed field path

score: u32 = GameManager.instance?.player?.score?

Capture one transactional class snapshot

manager: GameManager = GameManager.instance?.snapshot()?

Discover live instances cooperatively

let managers = await GameManager.instances()

Read a component from a scene hierarchy

let scene = unity.scenes.active() else return
let object = scene.find("Managers/GameManager") else return
let manager = object.component<GameManager>() else return