wiki.sine.space | sinespace

Difference between revisions of "Scripting/SUISlider"

From wiki.sine.space
Jump to: navigation, search
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suislider")
 
Line 1: Line 1:
==Members==
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suislider
{{ScriptFunction|void|OnValueChanged|(Closure callback);|Callback executed when the value of the slider is changed.|5=<pre>function valueChanged()
+
 
+
  Space.Log("value changed")
+
 
+
  end
+
 
+
Space.Host.ExecutingObject.UISlider.OnValueChanged(valueChanged)</pre>|6=<pre>--This script will make moving a slider control the Master Volume
+
--and also update a text field with the current Master Volume
+
--(example: custom UI)
+
--[You need to add the slider and text field as a reference]
+
 
+
slider = Space.Host.GetReference("Slider").UISlider
+
textField = Space.Host.GetReference("Text Field").UIText
+
 
+
 
+
OnValueChanged = function()
+
Space.UI.MasterVolume = slider.NormalizedValue * 100
+
textField.Text = Space.UI.MasterVolume
+
end
+
 
+
slider.OnValueChanged(OnValueChanged)</pre>}}
+
 
+
 
+
==Properties==
+
{{ScriptFunction|float|ColorMultiplier|{get;set}|This multiplies the tint color for each transition by its value.|5=
+
local slider=Space.Host.GetReference("Slider").UISlider<br>
+
Space.Log(slider.ColorMultiplier)
+
}}
+
{{ScriptFunction|Slider.Direction|Direction|{ get;set; }|The direction of the slider (0 to 4).
+
0 Left To Right, 1 Right To Left, 2 Bottom To Top, 3 Top To Bottom|5=<pre>Space.Host.ExecutingObject.UISlider.Direction = 1</pre>}}
+
 
+
{{ScriptFunction|SColor|DisabledColor|{get;set}|The color of the control when it is disabled.|5=
+
local slider=Space.Host.GetReference("Slider").UISlider<br>
+
Space.Log(slider.DisabledColor.ToString())
+
}}
+
 
+
{{ScriptFunction|bool|Enabled|{ get;set; }|Whether this Slider component is Enabled or not|5=<pre>Space.Host.ExecutingObject.UISlider.Enabled = false  --or false</pre>|6=<pre>--clicking this object will toggle a Sliders's Enabled status
+
 
+
thisGameObject = Space.Host.ExecutingObject
+
slider = Space.Host.GetReference("slider").UISlider
+
--make sure to add this reference to the Scripting Runtime component
+
 
+
 
+
OnClick = function()
+
slider.Enabled =  not slider.Enabled
+
end
+
 
+
 
+
thisGameObject.AddClickable()
+
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
+
 
+
{{ScriptFunction|SColor|HighlightedColor|{get;set}|The color of the control when it is highlighted.|5=
+
local slider=Space.Host.GetReference("Slider").UISlider<br>
+
Space.Log(slider.HighlightedColor.ToString())
+
}}
+
 
+
{{ScriptFunction|bool|Interactable|{ get;set;}|Use to enable or disable the ability to interact with the slider.|5=<pre>Space.Host.ExecutingObject.UISlider.Interactable = true</pre>|6=<pre>--clicking this object will toggle a Sliders's Interactable status
+
 
+
thisGameObject = Space.Host.ExecutingObject
+
slider = Space.Host.GetReference("slider").UISlider
+
--make sure to add this reference to the Scripting Runtime component
+
 
+
 
+
OnClick = function()
+
slider.Interactable =  not slider.Interactable
+
end
+
 
+
 
+
thisGameObject.AddClickable()
+
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
+
{{ScriptFunction|float|MaxValue|{ get;set; }|The maximum allowed value of the slider.|5=<pre>Space.Host.ExecutingObject.UISlider.MaxValue = 20</pre>}}
+
{{ScriptFunction|float|MinValue|{ get;set; }|The minimum allowed value of the slider.|5=<pre>Space.Host.ExecutingObject.UISlider.MinValue = 10</pre>}}
+
 
+
{{ScriptFunction|SColor|NormalColor|{get;set}|The normal color.|5=
+
local slider=Space.Host.GetReference("Slider").UISlider<br>
+
Space.Log(slider.NormalColor.ToString())
+
}}
+
{{ScriptFunction|float|NormalizedValue|{ get;set; }|The current value of the slider normalized into a value between 0 and 1.|5=<pre>Space.Log(Space.Host.ExecutingObject.UISlider.NormalizedValue)
+
--displays the current normalized value of the slider in the console</pre>|6=<pre>--This script will make moving a slider control the Master Volume
+
--and also update a text field with the current Master Volume
+
--(example: custom UI)
+
--[You need to add the slider and text field as a reference]
+
 
+
slider = Space.Host.GetReference("Slider").UISlider
+
textField = Space.Host.GetReference("Text Field").UIText
+
 
+
 
+
OnValueChanged = function()
+
Space.UI.MasterVolume = slider.NormalizedValue * 100
+
textField.Text = Space.UI.MasterVolume
+
end
+
 
+
slider.OnValueChanged(OnValueChanged)</pre>}}
+
 
+
{{ScriptFunction|SColor|PressedColor|{get;set}|The color of the control when it is pressed.|5=
+
local slider=Space.Host.GetReference("Slider").UISlider<br>
+
Space.Log(slider.PressedColor.ToString())
+
}}
+
 
+
{{ScriptFunction|float|Value|{ get;set; }|The current value of the slider.|5=<pre>Space.Log(Space.Host.ExecutingObject.UISlider.Value)
+
--displays the current value of the slider in the console</pre>}}
+
{{ScriptFunction|bool|WholeNumbers|{ get;set; }|Should the value only be allowed to be whole numbers?|5=<pre>Space.Host.ExecutingObject.UISlider.WholeNumbers = true --or false</pre>|6=<pre>--clicking this object will toggle a Sliders's Whole Numbers status
+
 
+
thisGameObject = Space.Host.ExecutingObject
+
slider = Space.Host.GetReference("slider").UISlider
+
--make sure to add this reference to the Scripting Runtime component
+
 
+
 
+
OnClick = function()
+
slider.WholeNumbers =  not slider.WholeNumbers
+
end
+
 
+
 
+
thisGameObject.AddClickable()
+
thisGameObject.Clickable.OnClick(OnClick)</pre>}}
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 06:45, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suislider