SUISlider
| دالة | OnValueChanged | Callback executed when the value of the slider is changed. |
| خاصية | Enabled | Whether this Slider component is Enabled or not |
| خاصية | Interactable | Use to enable or disable the ability to interact with the slider. |
| خاصية | Direction | The direction of the slider (0 to 4). 0 Left To Right, 1 Right To Left, 2 Bottom To Top, 3 Top To Bottom |
| خاصية | MinValue | The minimum allowed value of the slider. |
| خاصية | MaxValue | The maximum allowed value of the slider. |
| خاصية | WholeNumbers | Should the value only be allowed to be whole numbers? |
| خاصية | Value | The current value of the slider. |
| خاصية | NormalizedValue | The current value of the slider normalized into a value between 0 and 1. |
| خاصية | NormalColor | The normal color. |
| خاصية | HighlightedColor | The color of the control when it is highlighted. |
| خاصية | PressedColor | The color of the control when it is pressed. |
| خاصية | DisabledColor | The color of the control when it is disabled. |
| خاصية | ColorMultiplier | This multiplies the tint color for each transition by its value. |
| خاصية | GameObject | – |
الدوال
OnValueChanged
Callback executed when the value of the slider is changed.
المعاملات
| الاسم | النوع | القيمة الافتراضية |
|---|---|---|
| callback | Closure | – |
القيم المرجعة
void
مثال
function ValueChanged()
--
end
Space.Host.ExecutingObject.UISlider.OnValueChanged(ValueChanged)
--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)
الخصائص
Enabled
Whether this Slider component is Enabled or not
مثال
Space.Host.ExecutingObject.UISlider.Enabled = false
--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
Use to enable or disable the ability to interact with the slider.
مثال
Space.Host.ExecutingObject.UISlider.Interactable = true
--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
The direction of the slider (0 to 4). 0 Left To Right, 1 Right To Left, 2 Bottom To Top, 3 Top To Bottom
مثال
Space.Host.ExecutingObject.UISlider.Direction = 1
MinValue
The minimum allowed value of the slider.
مثال
Space.Host.ExecutingObject.UISlider.MinValue = 10
MaxValue
The maximum allowed value of the slider.
مثال
Space.Host.ExecutingObject.UISlider.MaxValue = 20
WholeNumbers
Should the value only be allowed to be whole numbers?
مثال
Space.Host.ExecutingObject.UISlider.WholeNumbers = true
--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
The current value of the slider.
مثال
Space.Host.ExecutingObject.UISlider.Value = 20
NormalizedValue
The current value of the slider normalized into a value between 0 and 1.
مثال
Space.Host.ExecutingObject.UISlider.NormalizedValue = 0.5
--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
The normal color.
مثال
Space.Host.ExecutingObject.UISlider.NormalColor = Color.Red
HighlightedColor
The color of the control when it is highlighted.
مثال
Space.Host.ExecutingObject.UISlider.HighlightedColor = Color.Red
PressedColor
The color of the control when it is pressed.
مثال
``` Space.Host.ExecutingObject.UISlider.PressedColor = Color.Red ```
DisabledColor
The color of the control when it is disabled.
مثال
lSpace.Host.ExecutingObject.UISlider.DisabledColor = Color.Red
ColorMultiplier
This multiplies the tint color for each transition by its value.
مثال
Space.Host.ExecutingObject.UISlider.ColorMultiplier = 1.2
GameObjectللقراءة فقط
مثال
theGameObject = Space.Host.ExecutingObject.UISlider.GameObject



