Breakroom is now Sinewave Campus. Book a meeting

SUISlider

ClientComponents
On this classOnValueChanged
  1. Functions
  2. OnValueChanged
  3. Properties
  4. Enabled
  5. Interactable
  6. Direction
  7. MinValue
  8. MaxValue
  9. WholeNumbers
  10. Value
  11. NormalizedValue
  12. NormalColor
  13. HighlightedColor
  14. PressedColor
  15. DisabledColor
  16. ColorMultiplier
  17. GameObject
Members 15
FunctionOnValueChangedCallback executed when the value of the slider is changed.
PropertyEnabledWhether this Slider component is Enabled or not
PropertyInteractableUse to enable or disable the ability to interact with the slider.
PropertyDirectionThe direction of the slider (0 to 4). 0 Left To Right, 1 Right To Left, 2 Bottom To Top, 3 Top To Bottom
PropertyMinValueThe minimum allowed value of the slider.
PropertyMaxValueThe maximum allowed value of the slider.
PropertyWholeNumbersShould the value only be allowed to be whole numbers?
PropertyValueThe current value of the slider.
PropertyNormalizedValueThe current value of the slider normalized into a value between 0 and 1.
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)

Callback executed when the value of the slider is changed.

Parameters

NameTypeDefault
callbackClosure–

Returns

void

Example

Lua
function ValueChanged()
--
end

Space.Host.ExecutingObject.UISlider.OnValueChanged(ValueChanged)
Lua
--This script will make moving a slider control the Master Volume
--and also update a text field with the current Master Volume
--[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)

Properties​

Enabled​

bool Enabled {get; set; }

Whether this Slider component is Enabled or not

Example

Lua
Space.Host.ExecutingObject.UISlider.Enabled = false
Lua
--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)

Interactable​

bool Interactable {get; set; }

Use to enable or disable the ability to interact with the slider.

Example

Lua
Space.Host.ExecutingObject.UISlider.Interactable = true
Lua
--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)

Direction​

int 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

Example

Lua
Space.Host.ExecutingObject.UISlider.Direction = 1

MinValue​

float MinValue {get; set; }

The minimum allowed value of the slider.

Example

Lua
Space.Host.ExecutingObject.UISlider.MinValue = 10

MaxValue​

float MaxValue {get; set; }

The maximum allowed value of the slider.

Example

Lua
Space.Host.ExecutingObject.UISlider.MaxValue = 20

WholeNumbers​

bool WholeNumbers {get; set; }

Should the value only be allowed to be whole numbers?

Example

Lua
Space.Host.ExecutingObject.UISlider.WholeNumbers = true
Lua
--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)

Value​

float Value {get; set; }

The current value of the slider.

Example

Lua
Space.Host.ExecutingObject.UISlider.Value = 20

NormalizedValue​

float NormalizedValue {get; set; }

The current value of the slider normalized into a value between 0 and 1.

Example

Lua
Space.Host.ExecutingObject.UISlider.NormalizedValue = 0.5
Lua
--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)

NormalColor​

SColor NormalColor {get; set; }

The normal color.

Example

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

HighlightedColor​

SColor HighlightedColor {get; set; }

The color of the control when it is highlighted.

Example

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

PressedColor​

SColor PressedColor {get; set; }

The color of the control when it is pressed.

Example

``` Space.Host.ExecutingObject.UISlider.PressedColor = Color.Red ```

DisabledColor​

SColor DisabledColor {get; set; }

The color of the control when it is disabled.

Example

Lua
lSpace.Host.ExecutingObject.UISlider.DisabledColor = Color.Red

ColorMultiplier​

float ColorMultiplier {get; set; }

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

Example

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

GameObjectRead only​

SGameObject GameObject {get; }

Example

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