Function: createToggle()
createToggle(
world,parent,options):Toggle
Defined in: ui/utilities/create-toggle.ts:124
Creates a toggle: a panel (see createPanel) with a
UiInteractableEcsComponent, a UiColorTransitionEcsComponent, and a
UiToggleEcsComponent added, plus a child checkmark panel whose
SpriteEcsComponent.enabled tracks isOn. Place a caption next to it with
a separate createLabel call - unlike createButton, a toggle doesn't
assemble one itself, since a caption's placement (left, right, above) and
whether one exists at all varies more than a button's centered label does.
Parameters
world
The ECS world to create the toggle entity in.
parent
number
The parent entity - a canvas (see createUiCanvas) or
another UI element.
options
Options for configuring the toggle. sprite and
checkmarkSprite have no sensible default and must always be provided.
Returns
The created toggle: its entity, its child checkmark entity, its
UiInteractableEcsComponent, its UiToggleEcsComponent, and
onValueChanged for the common case of registering a single listener.