# SUISlider

## Index

### Functions Index

| Function Name                                                 |
| ------------------------------------------------------------- |
| void [**OnValueChanged** ](#onvaluechanged)(Closure callback) |

### Properties Index

| Property Name                                                |
| ------------------------------------------------------------ |
| bool [**Enabled** ](#enabled)`get` `set`                     |
| bool [**Interactable** ](#interactable)`get` `set`           |
| int [**Direction** ](#direction)`get` `set`                  |
| float [**MinValue** ](#minvalue)`get` `set`                  |
| float [**MaxValue** ](#maxvalue)`get` `set`                  |
| bool [**WholeNumbers** ](#wholenumbers)`get` `set`           |
| float [**Value** ](#value)`get` `set`                        |
| float [**NormalizedValue** ](#normalizedvalue)`get` `set`    |
| SColor [**NormalColor** ](#normalcolor)`get` `set`           |
| SColor [**HighlightedColor** ](#highlightedcolor)`get` `set` |
| SColor [**PressedColor** ](#pressedcolor)`get` `set`         |
| SColor [**DisabledColor** ](#disabledcolor)`get` `set`       |
| float [**ColorMultiplier** ](#colormultiplier)`get` `set`    |
| SGameObject [**GameObject** ](#gameobject)`get`              |

## Functions

### OnValueChanged

void **OnValueChanged** (Closure callback)

*Callback executed when the value of the slider is changed.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
function ValueChanged()
--
end

Space.Host.ExecutingObject.UISlider.OnValueChanged(ValueChanged)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```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)
```

{% endtab %}
{% endtabs %}

## Properties

### Enabled

bool **Enabled** `get` `set`

*Whether this Slider component is Enabled or not*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.Enabled = false 
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```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)
```

{% endtab %}
{% endtabs %}

### Interactable

bool **Interactable** `get` `set`

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

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.Interactable = true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```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)
```

{% endtab %}
{% endtabs %}

### 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*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.Direction = 1
```

{% endtab %}
{% endtabs %}

### MinValue

float **MinValue** `get` `set`

*The minimum allowed value of the slider.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.MinValue = 10
```

{% endtab %}
{% endtabs %}

### MaxValue

float **MaxValue** `get` `set`

*The maximum allowed value of the slider.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.MaxValue = 20
```

{% endtab %}
{% endtabs %}

### WholeNumbers

bool **WholeNumbers** `get` `set`

*Should the value only be allowed to be whole numbers?*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.WholeNumbers = true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```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)
```

{% endtab %}
{% endtabs %}

### Value

float **Value** `get` `set`

*The current value of the slider.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.Value = 20
```

{% endtab %}
{% endtabs %}

### NormalizedValue

float **NormalizedValue** `get` `set`

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

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.NormalizedValue = 0.5
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```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)
```

{% endtab %}
{% endtabs %}

### NormalColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **NormalColor** `get` `set`

*The normal color.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.NormalColor = Color.Red
```

{% endtab %}
{% endtabs %}

### HighlightedColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **HighlightedColor** `get` `set`

*The color of the control when it is highlighted.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.HighlightedColor = Color.Red
```

{% endtab %}
{% endtabs %}

### PressedColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **PressedColor** `get` `set`

*The color of the control when it is pressed.*

{% tabs %}
{% tab title="Lua" %}

<pre class="language-lua"><code class="lang-lua"><strong>Space.Host.ExecutingObject.UISlider.PressedColor = Color.Red
</strong></code></pre>

{% endtab %}
{% endtabs %}

### DisabledColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **DisabledColor** `get` `set`

*The color of the control when it is disabled.*

{% tabs %}
{% tab title="Lua" %}

```lua
lSpace.Host.ExecutingObject.UISlider.DisabledColor = Color.Red
```

{% endtab %}
{% endtabs %}

### ColorMultiplier

float **ColorMultiplier** `get` `set`

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

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UISlider.ColorMultiplier = 1.2
```

{% endtab %}
{% endtabs %}

### GameObject

[SGameObject](https://docs.sine.space/scripting/client-scripting-api-reference/types/sgameobject) **GameObject** `get`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
theGameObject = Space.Host.ExecutingObject.UISlider.GameObject
```

{% endtab %}
{% endtabs %}
