UI Toggle Switch
On/off switch.
Type: UIToggleSwitchNode · Category: UI & Interface · Also found as: uitoggleswitch
Properties
Section titled “Properties”| Property | Type | Default | Description |
|---|---|---|---|
size |
vec2 | (140, 24) |
Width and height (px). Range 4 to 1280. |
label |
string | "Toggle" |
Caption shown next to the control. |
active |
boolean | false |
Switched on. |
Plus the common properties every node has.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
UIToggleSwitchNode:get_property(path)
Section titled “UIToggleSwitchNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("size")pathUIToggleSwitchNodeProperty|string
Returns any
UIToggleSwitchNode:set_property(path, value, y)
Section titled “UIToggleSwitchNode:set_property(path, value, y)”Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.
self.node:set_property("size", 100, 50)pathUIToggleSwitchNodeProperty|stringvalueanyy?number
In a scene file
Section titled “In a scene file”{ "type": "UIToggleSwitchNode", "name": "UIToggleSwitch", "position": [ 0, 0 ], "properties": { "size": [ 140, 24 ], "label": "Toggle", "active": false }}