Skip to main content

Function: createSlider()

createSlider(world, parent, options): Slider

Defined in: ui/utilities/create-slider.ts:147

Creates a slider: a panel (see createPanel) used as the drag track, with a UiInteractableEcsComponent, a UiColorTransitionEcsComponent, and a UiSliderEcsComponent added, plus a child handle (and, if fillSprite is given, a child fill) whose rect transforms createUiSliderEcsSystem drives from the slider's value every tick. The whole track is the drag surface - clicking anywhere on it, not just the handle, jumps the handle there.

Parameters​

world​

EcsWorld

The ECS world to create the slider entity in.

parent​

number

The parent entity - a canvas (see createUiCanvas) or another UI element.

options​

CreateSliderOptions

Options for configuring the slider. trackSprite and handleSprite have no sensible default and must always be provided.

Returns​

Slider

The created slider: its track entity, its child handle (and fill, if any) entity, its UiInteractableEcsComponent, its UiSliderEcsComponent, and onValueChanged for the common case of registering a single listener.