Skip to content

API Class UIView

github-actions[bot] edited this page Dec 3, 2026 · 7 revisions

Class: UIView

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

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

Implements

  • ScreenView

Constructors

Constructor

new UIView(): UIView;

Returns

UIView

Inherited from

Component.constructor

Properties

autoFocus

autoFocus: boolean = false;

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

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


bind

bind: Record<string, string[]> = {};

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

ADR 0681: queries it binds, by prop name ({ ships: ["pirates.Captain", "pirates.Awareness"] }). Each prop is a store of plain rows, one per node with every listed component ({ entity, id, captain: {…}, awareness: {…} }: entity for a keyed {#each}, id the node's id), updated as nodes join, leave or change. Nodes in a scene being edited match only a view that is too. Read when it mounts: replacing the object mounts it again.


cancelPops

cancelPops: boolean = true;

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

ADR 0668: the UI cancel action (Escape, the east button) on this screen, while on top, takes it off (false: a root menu that stays).

Implementation of

ScreenView.cancelPops


component

component: string = "";

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

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


dataProps

dataProps: Record<string, string> = {};

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

ADR 0681: the data components of its node it shows, by the prop name its component reads ({ hudPlayer: "pirates.HudPlayer" }). Each prop is a store of the component's fields as plain values ($hudPlayer.hp), set when the row changes; null while the node doesn't have it. Read when it mounts: replacing the object mounts it again.


firstSelected

firstSelected: string = "";

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

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:75

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


maxUpdateRate

maxUpdateRate: number = 0;

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

How many times a second its UI updates at most; 0: every frame (ADR 0667, as Ultralight's set_max_render_fps). Between updates the component's queued changes wait and its elements aren't restyled, so they hold still and cost nothing to lay out; each update catches up on what changed since. Counted in the World's unscaled time, so a paused game's UI still updates. Input to one of its elements, a resize of its canvas and enabling the view update it at once. For secondary views (a scoreboard, a world-space panel) whose changes needn't show every frame.

Not capped: CSS transitions and keyframe animations already running, requestAnimationFrame callbacks, and changes Svelte applies outside this view's frame flush (its own microtask between frames, or another view's flush: Svelte flushes every component at once). Text and elements those write show when they happen; the restyles they cause (classes, inline styles) still wait for the next update.


modal

modal: boolean = false;

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

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:71

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


path

path: string = "";

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

ADR 0668: a screen's path pattern, with parameters (/results/:matchId); empty: / and the route.

Implementation of

ScreenView.path


pixelSize

pixelSize: number = 0.01;

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

World mode: world units per UI pixel.


referenceResolution

referenceResolution: Vector2;

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

The UI's design size in UI pixels.


route

route: string = "";

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

ADR 0668: its name as a screen (results), for UIScreens.push("results"). A view with a route is shown only while it's in its World's screen stack (edit mode shows it as authored); empty: not a screen, shown while active.

Implementation of

ScreenView.route


sortOrder

sortOrder: number = 0;

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

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:131

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:173

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


player

Get Signature

get player(): number;

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

The local player whose UI actions drive it (ADR 0681): the nearest ControlledBy { player } up its hierarchy; -1 without one (any local player).

Returns

number


props

Get Signature

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

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

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:161

Parameters
value

Record<string, unknown>

Returns

void


ready

Get Signature

get ready(): Promise<void>;

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

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:192

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:202

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:207

Every rendered element a selector matches, in tree order.

Parameters

selector

string

Returns

UIViewElement[]

Clone this wiki locally