Skip to content

API Class UIView

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

Class: UIView

Defined in: src/plugins/ui/runtime/UIView.ts:59

Base class for everything attached to a node: built-in engine components and user GameBehaviors (ADR 0007, 0009). Instances are created by the engine (node.addBehavior(Type) or scene loading), never with new by game code.

Extends

Constructors

Constructor

new UIView(): UIView;

Returns

UIView

Inherited from

Component.constructor

Properties

autoFocus

autoFocus: boolean = false;

Defined in: src/plugins/ui/runtime/UIView.ts:75

Focus firstSelected (else the first focusable element) when the view becomes active.


component

component: string = "";

Defined in: src/plugins/ui/runtime/UIView.ts:61

The Svelte component (asset:ui/hud.svelte).


firstSelected

firstSelected: string = "";

Defined in: src/plugins/ui/runtime/UIView.ts:81

Where autoFocus, a modal view, and navigate with nothing focused put focus (ADR 0340): the id of an element the component renders ("options" or "#options"), followed as it re-renders (the element that has the id now, none once it's gone). Empty: the first focusable element.


matchHeight

matchHeight: number = 1;

Defined in: src/plugins/ui/runtime/UIView.ts:67

0: scale with the canvas width; 1: with its height; between: a blend.


modal

modal: boolean = false;

Defined in: src/plugins/ui/runtime/UIView.ts:73

While it has a focusable element, focus can't leave it (ADR 0340).


mode

mode: UICanvasMode = "screen";

Defined in: src/plugins/ui/runtime/UIView.ts:63

The canvas's settings (as UICanvas's): screen covers the canvas, world is a panel in the scene.


pixelSize

pixelSize: number = 0.01;

Defined in: src/plugins/ui/runtime/UIView.ts:71

World mode: world units per UI pixel.


player

player: number = -1;

Defined in: src/plugins/ui/runtime/UIView.ts:83

The local player whose UI actions drive it; -1: any local player.


referenceResolution

referenceResolution: Vector2;

Defined in: src/plugins/ui/runtime/UIView.ts:65

The UI's design size in UI pixels.


sortOrder

sortOrder: number = 0;

Defined in: src/plugins/ui/runtime/UIView.ts:69

Screen canvases draw (and take the pointer) in ascending order: higher is on top. A whole number, as Unity's (ADR 0662): a fraction sorts rounded.


transformError

transformError: ((error) => unknown) | null = null;

Defined in: src/plugins/ui/runtime/UIView.ts:90

Svelte's transformError (ADR 0423): turns an error a <svelte:boundary> catches into what its failed snippet and onerror get (a framework's error hook: a message safe to show, an error id). Read when an error is caught, so setting it takes effect at once; null passes errors through unchanged.

Accessors

enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:63

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:67

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


exports

Get Signature

get exports(): Record<string, unknown> | null;

Defined in: src/plugins/ui/runtime/UIView.ts:122

The root component's exports while it's mounted (what Svelte's mount returns: its export const and export function values), or null before it mounts. A remount (re-enabling, hot reload) gives a new object.

Returns

Record<string, unknown> | null


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:43

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:74

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Component.isActiveAndEnabled


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:38

The node this component is on.

Returns

GameObject

Inherited from

Component.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:51

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Component.owner


props

Get Signature

get props(): Record<string, unknown>;

Defined in: src/plugins/ui/runtime/UIView.ts:107

The component's props. Reactive once mounted: view.props.score = 10 (or a change inside a prop's object or array) shows in the same frame. Assigning an object replaces every prop.

Returns

Record<string, unknown>

Set Signature

set props(value): void;

Defined in: src/plugins/ui/runtime/UIView.ts:111

Parameters
value

Record<string, unknown>

Returns

void


ready

Get Signature

get ready(): Promise<void>;

Defined in: src/plugins/ui/runtime/UIView.ts:127

Resolves once the component is mounted (at once if it is).

Returns

Promise<void>


root

Get Signature

get root(): UIViewElement | null;

Defined in: src/plugins/ui/runtime/UIView.ts:133

The canvas the component renders into, or null before it's mounted.

Returns

UIViewElement | null


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:99

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Component.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:57

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Component.transform


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:88

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Component.world

Methods

instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:109

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Component.instantiate


query()

query(selector): UIViewElement | null;

Defined in: src/plugins/ui/runtime/UIView.ts:143

The first rendered element a selector matches (#play, .row button), or null.

Parameters

selector

string

Returns

UIViewElement | null


queryAll()

queryAll(selector): UIViewElement[];

Defined in: src/plugins/ui/runtime/UIView.ts:148

Every rendered element a selector matches, in tree order.

Parameters

selector

string

Returns

UIViewElement[]

Clone this wiki locally