wiki.sine.space | sinespace

Difference between revisions of "Scripting/SUIToggle"

From wiki.sine.space
Jump to: navigation, search
Line 24: Line 24:
 
=Properties=
 
=Properties=
  
{{ScriptFunction|bool|Enabled|{ get;set; }|Whether the UIToggle is Enabled or not|5= <pre>Space.Host.ExecutingObject.UIToggle.Enabled = true</pre>}}
+
{{ScriptFunction|bool|Enabled|{ get;set; }|Whether the UIToggle is Enabled or not|5= <pre>Space.Host.ExecutingObject.UIToggle.Enabled = true</pre>|6=<pre>--clicking this object will toggle a Toggles's Enabled status
  
{{ScriptFunction|bool|Interactable|{ get;set; }|Whether the UIToggle is Interactable or not|5= <pre>Space.Host.ExecutingObject.UIToggle.Interactable = true</pre>}}
+
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)</pre>}}
 +
 
 +
{{ScriptFunction|bool|Interactable|{ get;set; }|Whether the UIToggle is Interactable or not|5= <pre>Space.Host.ExecutingObject.UIToggle.Interactable = true</pre>|6=<pre>--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)</pre>}}
  
 
{{ScriptFunction|bool|IsOn|{ get;set; }|Whether the UIToggle is toggled On or Off|5= <pre>Space.Host.ExecutingObject.UIToggle.IsOn = true</pre>|6=<pre>--This script will make a UI Toggle show/hide the Notification Button
 
{{ScriptFunction|bool|IsOn|{ get;set; }|Whether the UIToggle is toggled On or Off|5= <pre>Space.Host.ExecutingObject.UIToggle.IsOn = true</pre>|6=<pre>--This script will make a UI Toggle show/hide the Notification Button

Revision as of 06:28, 13 October 2021

Members

OnValueChanged

void OnValueChanged (Closure callback)

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

ovc = function()
  Space.Log("Toggled")
  end
Space.Host.ExecutingObject.UIToggle.OnValueChanged(ovc)


--This script will make a UI Toggle show/hide the Notification Button
--(example: tools for user to customize UI)
--[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 or not

Space.Host.ExecutingObject.UIToggle.Enabled = true


--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 or not

Space.Host.ExecutingObject.UIToggle.Interactable = true


--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 or Off

Space.Host.ExecutingObject.UIToggle.IsOn = true


--This script will make a UI Toggle show/hide the Notification Button
--(example: tools for user to customize UI)
--[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.

local toggle=Space.Host.GetReference("Toggle").UIToggle
Space.Log(toggle.NormalColor.ToString())


HighlightedColor

SColor HighlightedColor {get;set}

The color of the control when it is highlighted.

local toggle=Space.Host.GetReference("Toggle").UIToggle
Space.Log(toggle.HighlightedColor.ToString())


PressedColor

SColor PressedColor {get;set}

The color of the control when it is pressed.

local toggle=Space.Host.GetReference("Toggle").UIToggle
Space.Log(toggle.PressedColor.ToString())


DisabledColor

SColor DisabledColor {get;set}

The color of the control when it is disabled.

local toggle=Space.Host.GetReference("Toggle").UIToggle
Space.Log(toggle.DisabledColor.ToString())


ColorMultiplier

float ColorMultiplier {get;set}

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

local toggle=Space.Host.GetReference("Toggle").UIToggle
Space.Log(toggle.ColorMultiplier)