Skip to content

API Class UIText

github-actions[bot] edited this page Nov 24, 2026 · 7 revisions

Class: UIText

Defined in: src/engine/ui/components.ts:148

Text laid out as an element. Its font is the bundled Inter (weights 100–900; Latin, Latin-1 and common punctuation, other characters falling back to the system font), or the project font file font names.

Extends

  • UIElement

Constructors

Constructor

new UIText(): UIText;

Returns

UIText

Inherited from

UIElement.constructor

Properties

alignItems

alignItems: UIAlign = "stretch";

Defined in: src/engine/ui/components.ts:93

Inherited from

UIElement.alignItems


bottom

bottom: UILength = "auto";

Defined in: src/engine/ui/components.ts:107

Inherited from

UIElement.bottom


color

color: Color = Color.white;

Defined in: src/engine/ui/components.ts:156


display

display: UIDisplay = "flex";

Defined in: src/engine/ui/components.ts:120

none removes the element and its children from layout, drawing and the pointer, like CSS display: none, while its node stays active (its scripts run, and its state reads as before). flex (the default) lays it out.

Inherited from

UIElement.display


flexDirection

flexDirection: UIFlexDirection = "row";

Defined in: src/engine/ui/components.ts:91

How this element lays out its children.

Inherited from

UIElement.flexDirection


flexGrow

flexGrow: number = 0;

Defined in: src/engine/ui/components.ts:110

How much of the parent's free space this element takes, relative to its siblings.

Inherited from

UIElement.flexGrow


font

font: string = "";

Defined in: src/engine/ui/components.ts:154

A font file in the project (asset:fonts/Pirata.ttf; .ttf, .otf, .woff or .woff2), loaded the first time it's used; empty is the bundled Inter. Characters the font lacks use Inter.


fontSize

fontSize: number = 16;

Defined in: src/engine/ui/components.ts:155


fontWeight

fontWeight: string = "normal";

Defined in: src/engine/ui/components.ts:158

"light" (300), "normal" (400), "medium" (500), "semi-bold" (600), "bold" (700), or a whole number 1–1000 (anything else is 400).


gap

gap: number = 0;

Defined in: src/engine/ui/components.ts:95

Space between children.

Inherited from

UIElement.gap


height

height: UILength = "auto";

Defined in: src/engine/ui/components.ts:102

Inherited from

UIElement.height


justifyContent

justifyContent: UIJustify = "flex-start";

Defined in: src/engine/ui/components.ts:92

Inherited from

UIElement.justifyContent


left

left: UILength = "auto";

Defined in: src/engine/ui/components.ts:108

Inherited from

UIElement.left


margin

margin: number = 0;

Defined in: src/engine/ui/components.ts:99

Space around the element, on every side.

Inherited from

UIElement.margin


opacity

opacity: number = 1;

Defined in: src/engine/ui/components.ts:112

0..1, multiplied into its children's.

Inherited from

UIElement.opacity


padding

padding: number = 0;

Defined in: src/engine/ui/components.ts:97

Space inside the element, on every side.

Inherited from

UIElement.padding


positionType

positionType: UIPositionType = "relative";

Defined in: src/engine/ui/components.ts:104

absolute takes the element out of its parent's flow, placed by top/right/bottom/left.

Inherited from

UIElement.positionType


raycastTarget

raycastTarget: boolean = true;

Defined in: src/engine/ui/components.ts:129

Whether the pointer stops at this element, like Unity's Graphic.raycastTarget (ADR 0385). True (the default): a press over it goes to the UI, never to the game (Input.pointerOverUI is true), and reaches the button or input field it's in, if any; over text, an image or a panel outside one, it does nothing. False: the pointer passes through to whatever is behind it (other UI, or the game). Text, images, buttons and input fields stop it; a panel only when it draws a background (even a transparent one) or a border, as a panel without either is a layout box (Unity's empty RectTransform). Children aren't affected: each element has its own.

Inherited from

UIElement.raycastTarget


right

right: UILength = "auto";

Defined in: src/engine/ui/components.ts:106

Inherited from

UIElement.right


text

text: string = "";

Defined in: src/engine/ui/components.ts:149


textAlign

textAlign: UITextAlign = "start";

Defined in: src/engine/ui/components.ts:160

start (the default) and end follow the language's direction: start is left in English, right in Arabic.


top

top: UILength = "auto";

Defined in: src/engine/ui/components.ts:105

Inherited from

UIElement.top


visible

visible: boolean = true;

Defined in: src/engine/ui/components.ts:114

False hides the element and its children but keeps its space (a disabled component or inactive node takes none).

Inherited from

UIElement.visible


width

width: UILength = "auto";

Defined in: src/engine/ui/components.ts:101

Pixels (120), a percentage of the parent ("50%") or "auto" (sized by its content).

Inherited from

UIElement.width


wordBreak

wordBreak: UIWordBreak = "break-word";

Defined in: src/engine/ui/components.ts:162

How lines wrap: at word boundaries, anywhere, or never.

Accessors

enabled

Get Signature

get enabled(): boolean;

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

Returns

boolean

Set Signature

set enabled(value): void;

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

Parameters
value

boolean

Returns

void

Inherited from

UIElement.enabled


gameObject

Get Signature

get gameObject(): GameObject;

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

Unity-style alias for node.

Returns

GameObject

Inherited from

UIElement.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

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

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

Returns

boolean

Inherited from

UIElement.isActiveAndEnabled


node

Get Signature

get node(): GameObject;

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

The node this component is on.

Returns

GameObject

Inherited from

UIElement.node


owner

Get Signature

get owner(): GameObject;

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

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

UIElement.owner


time

Get Signature

get time(): Readonly<TimeState>;

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

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

UIElement.time


transform

Get Signature

get transform(): Transform;

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

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

Returns

Transform

Inherited from

UIElement.transform


world

Get Signature

get world(): WorldHandle;

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

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

UIElement.world

Methods

instantiate()

instantiate(prefabPath, options?): GameObject;

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

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

UIElement.instantiate

Clone this wiki locally