UI Toggle Button
Updated
A button that stays on until clicked again.
- Type
comp-ui-toggle-button- Script class
UIToggleButtonComponent- Per entity
- One
- Version
- 1.2.0
Read about it in Controls: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
badge |
0 ≤ x ≤ 1000000 |
|
borderRadius |
||
border |
0 ≤ x ≤ 16384 |
|
borderWidth |
||
borderWidth[] |
0 ≤ x ≤ 16384 |
|
fontSize |
0 ≤ x ≤ 4096 |
|
margin |
||
margin[] |
- |
|
padding |
||
padding[] |
0 ≤ x ≤ 16384 |
|
size |
0 ≤ x ≤ 4096 |
|
sizeScale |
0 ≤ x |
Events
Section titled “Events”Sent to the entity’s Signal Emitter as { entityId, eventType, data }. Compare eventType with the EventType constants.
UIToggleButton::change
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
A video playerA UI Video in a panel with a UI Toggle Button that plays and pauses it and a volume slider; the button's label follows the video's own play and pause events.
Press Play to start the video with sound, press again to pause, and drag the slider to change the volume. Drag outside the panel to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(UIToggleButtonComponent); if (component) log(component.props);}