SUIToggle
客户端组件
成员 10
| 函数 | OnValueChanged | Binds a function to be triggered when value of the UIToggle changes. |
| 属性 | Enabled | Whether the UIToggle is Enabled |
| 属性 | Interactable | Whether the UIToggle is Interactable |
| 属性 | IsOn | Whether the UIToggle is toggled On |
| 属性 | 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
void OnValueChanged(Closure callback)
Binds a function to be triggered when value of the UIToggle changes.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| callback | Closure | – |
返回值
void
示例
Lua
function ovc()
--
end
Space.Host.ExecutingObject.UIToggle.OnValueChanged(ovc)
Lua
--This script will make a UI Toggle show/hide the Notification Button
--[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)
属性
Enabled
bool Enabled {get; set; }
Whether the UIToggle is Enabled
示例
Lua
Space.Host.ExecutingObject.UIToggle.Enabled = true
Lua
--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
示例
Lua
Space.Host.ExecutingObject.UIToggle.Interactable = true
Lua
--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
示例
Lua
Space.Host.ExecutingObject.UIToggle.IsOn = true
Lua
--This script will make a UI Toggle show/hide the Notification Button
--[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.
示例
Lua
Space.Host.ExecutingObject.UIToggle.NormalColor = Color.Red
HighlightedColor
The color of the control when it is highlighted.
示例
Lua
Space.Host.ExecutingObject.UIToggle.HighlightedColor = Color.Red
PressedColor
The color of the control when it is pressed.
示例
Lua
Space.Host.ExecutingObject.UIToggle.PressedColor = Color.Red
DisabledColor
The color of the control when it is disabled.
示例
Lua
Space.Host.ExecutingObject.UIToggle.DisabledColor = Color.Red
ColorMultiplier
float ColorMultiplier {get; set; }
This multiplies the tint color for each transition by its value.
示例
Lua
Space.Host.ExecutingObject.UIToggle.ColorMultiplier = 1.2
GameObject只读
示例
Lua
theGameObject = Space.Host.ExecutingObject.UIToggle.GameObject



