Breakroom is now Sinewave Campus. Book a meeting

SUIToggle

ClientComponents
On this classOnValueChanged
  1. Functions
  2. OnValueChanged
  3. Properties
  4. Enabled
  5. Interactable
  6. IsOn
  7. NormalColor
  8. HighlightedColor
  9. PressedColor
  10. DisabledColor
  11. ColorMultiplier
  12. GameObject
Members 10
FunctionOnValueChangedBinds a function to be triggered when value of the UIToggle changes.
PropertyEnabledWhether the UIToggle is Enabled
PropertyInteractableWhether the UIToggle is Interactable
PropertyIsOnWhether the UIToggle is toggled On
PropertyNormalColorThe normal color.
PropertyHighlightedColorThe color of the control when it is highlighted.
PropertyPressedColorThe color of the control when it is pressed.
PropertyDisabledColorThe color of the control when it is disabled.
PropertyColorMultiplierThis multiplies the tint color for each transition by its value.
PropertyGameObject–

Functions​

OnValueChanged​

void OnValueChanged(Closure callback)

Binds a function to be triggered when value of the UIToggle changes.

Parameters

NameTypeDefault
callbackClosure–

Returns

void

Example

Lua
function ovc()
--
end
Space.Host.ExecutingObject.UIToggle.OnValueChanged(ovc)
Lua
--This script will make a UI Toggle show/hide the Notification Button
--[You need to add an object with UI Toggle as a reference (scripting runtime)]

toggle = Space.Host.GetReference("Toggle").UIToggle


OnValueChanged = function()
if toggle.IsOn then
Space.UI.ShowNotificationButton= true
else
Space.UI.ShowNotificationButton= false
end
end

toggle.OnValueChanged(OnValueChanged)

Properties​

Enabled​

bool Enabled {get; set; }

Whether the UIToggle is Enabled

Example

Lua
Space.Host.ExecutingObject.UIToggle.Enabled = true
Lua
--clicking this object will toggle a Toggles's Enabled status

thisGameObject = Space.Host.ExecutingObject
toggle = Space.Host.GetReference("toggle").UIToggle
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
toggle.Enabled = not toggle.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

Interactable​

bool Interactable {get; set; }

Whether the UIToggle is Interactable

Example

Lua
Space.Host.ExecutingObject.UIToggle.Interactable = true
Lua
--clicking this object will toggle a Toggles's Interactable status

thisGameObject = Space.Host.ExecutingObject
toggle = Space.Host.GetReference("toggle").UIToggle
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
toggle.Interactable= not toggle.Interactable
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

IsOn​

bool IsOn {get; set; }

Whether the UIToggle is toggled On

Example

Lua
Space.Host.ExecutingObject.UIToggle.IsOn = true
Lua
--This script will make a UI Toggle show/hide the Notification Button
--[You need to add an object with UI Toggle as a reference (scripting runtime)]

toggle = Space.Host.GetReference("Toggle").UIToggle


OnValueChanged = function()
if toggle.IsOn then
Space.UI.ShowNotificationButton= true
else
Space.UI.ShowNotificationButton= false
end
end

toggle.OnValueChanged(OnValueChanged)

NormalColor​

SColor NormalColor {get; set; }

The normal color.

Example

Lua
Space.Host.ExecutingObject.UIToggle.NormalColor = Color.Red

HighlightedColor​

SColor HighlightedColor {get; set; }

The color of the control when it is highlighted.

Example

Lua
Space.Host.ExecutingObject.UIToggle.HighlightedColor = Color.Red

PressedColor​

SColor PressedColor {get; set; }

The color of the control when it is pressed.

Example

Lua
Space.Host.ExecutingObject.UIToggle.PressedColor = Color.Red

DisabledColor​

SColor DisabledColor {get; set; }

The color of the control when it is disabled.

Example

Lua
Space.Host.ExecutingObject.UIToggle.DisabledColor = Color.Red

ColorMultiplier​

float ColorMultiplier {get; set; }

This multiplies the tint color for each transition by its value.

Example

Lua
Space.Host.ExecutingObject.UIToggle.ColorMultiplier = 1.2

GameObjectRead only​

SGameObject GameObject {get; }

Example

Lua
theGameObject = Space.Host.ExecutingObject.UIToggle.GameObject