Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / UIToggleComponent

Class: UIToggleComponent ​

Defined in: components/UIToggle.ts:30

An on/off switch.

The knob is a separate quad positioned from value — flipping animates geometry, never redrawing the canvas. Scripts hear changes via Behaviour.onUiToggle (bubbling like button presses); value is authored state and persists with the scene.

Extends ​

Constructors ​

Constructor ​

ts
new UIToggleComponent(options?): UIToggleComponent;

Defined in: components/UIToggle.ts:54

Parameters ​

ParameterType
options?UIToggleOptions

Returns ​

UIToggleComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDescriptionDefined in
valueboolean-components/UIToggle.ts:31
actionIdstringDispatch identifier; empty string means "use the entity name".components/UIToggle.ts:33
widthnumberFull width in metres.components/UIToggle.ts:35
heightnumberFull height in metres.components/UIToggle.ts:37
trackColorstringTrack colour while OFF.components/UIToggle.ts:39
accentColorstringTrack colour while ON.components/UIToggle.ts:41
knobColorstring-components/UIToggle.ts:42
pixelDensity?numberTexture density in px/metre, clamped 256–2048 at render time. Absent means the default: a defaulted field would count as a change on every instance of a prefab saved before it existed.components/UIToggle.ts:48
style?UiStyleModern styling; wins over the flat fields above. Absent until authored.components/UIToggle.ts:50
variant?UiToggleVariantHow the control is drawn. Absent means switch.components/UIToggle.ts:52