Skip to content

Class: ToggleComponent ​

A checkbox / radio button (Unity's Toggle, Cocos's Toggle). A tap flips isOn; checkmark is an entity ToggleSystem shows while it's on (edit mode too). With a group (an entity with a ToggleGroupComponent) turning one on turns the others off.

Writing isOn from code behaves like a tap: the checkmark, the group and the events follow. EntityEvent.ToggleChanged on the toggle (payload: isOn) while the game runs. Add a Button beside it for press feedback — Toggle mirrors its interactable into the Button.

Extends ​

Constructors ​

Constructor ​

ts
new ToggleComponent(): ToggleComponent;

Returns ​

ToggleComponent

Inherited from ​

Component.constructor

Properties ​

PropertyModifierTypeDefault valueInherited from
checkmarkpublicnumber | nullundefined-
dirtypublicbooleantrueComponent.dirty
enabledpublicbooleantrueComponent.enabled
grouppublicnumber | nullundefined-
interactablepublicbooleanundefined-
isOnpublicbooleanundefined-

Methods ​

SetCheckmark() ​

ts
SetCheckmark(target): void;

Parameters ​

ParameterType
targetnumber | Entity | null

Returns ​

void


SetGroup() ​

ts
SetGroup(target): void;

Parameters ​

ParameterType
targetnumber | Entity | null

Returns ​

void


Toggle() ​

ts
Toggle(): void;

Returns ​

void

© 2026 PlayAdGentic