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
Properties
| Property | Modifier | Type | Default value | Inherited from |
|---|---|---|---|---|
checkmark | public | number | null | undefined | - |
dirty | public | boolean | true | Component.dirty |
enabled | public | boolean | true | Component.enabled |
group | public | number | null | undefined | - |
interactable | public | boolean | undefined | - |
isOn | public | boolean | undefined | - |
Methods
SetCheckmark()
ts
SetCheckmark(target): void;Parameters
| Parameter | Type |
|---|---|
target | number | Entity | null |
Returns
void
SetGroup()
ts
SetGroup(target): void;Parameters
| Parameter | Type |
|---|---|
target | number | Entity | null |
Returns
void
Toggle()
ts
Toggle(): void;Returns
void