Breakroom is now Sinewave Campus. Book a meeting

SUIButton

客户端组件
在此类中OnClick
  1. 函数
  2. OnClick
  3. 属性
  4. Enabled
  5. Interactable
  6. NormalColor
  7. HighlightedColor
  8. PressedColor
  9. DisabledColor
  10. ColorMultiplier
  11. GameObject
成员 9
函数OnClickInvoke when a user clicks the button and releases it.
属性EnabledWhether the button component is Enabled.
属性InteractableEnable Interactable if you want this button to accept input.
属性NormalColorThe normal color of the control.
属性HighlightedColorThe color of the control when it is highlighted.
属性PressedColorThe color of the control when it is pressed.
属性DisabledColorThe color of the control when it is disabled.
属性ColorMultiplierThis multiplies the tint color for each transition by its value.
属性GameObject–

函数​

OnClick​

void OnClick(Closure callback)

Invoke when a user clicks the button and releases it.

参数

名称类型默认值
callbackClosure–

返回值

void

示例

Lua
function OnClickFunction()
--
end

Space.Host.ExecutingObject.UIButton.OnClick(OnClickFunction)

属性​

Enabled​

bool Enabled {get; set; }

Whether the button component is Enabled.

示例

Lua
Space.Host.ExecutingObject.UIButton.Enabled = true
Lua
--clicking this object will toggle Enable/Disable an object's Button component

thisGameObject = Space.Host.ExecutingObject
button = Space.Host.GetReference("button").UIButton
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
button.Enabled = not button.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

Interactable​

bool Interactable {get; set; }

Enable Interactable if you want this button to accept input.

示例

Lua
Space.Host.ExecutingObject.UIButton.Interactable = true
Lua
--clicking this object will toggle Interactable status on an object's Button component

thisGameObject = Space.Host.ExecutingObject
button = Space.Host.GetReference("button").UIButton
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
button.Interactable= not button.Interactable
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

NormalColor​

SColor NormalColor {get; set; }

The normal color of the control.

示例

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

HighlightedColor​

SColor HighlightedColor {get; set; }

The color of the control when it is highlighted.

示例

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

PressedColor​

SColor PressedColor {get; set; }

The color of the control when it is pressed.

示例

Lua
Space.Host.ExecutingObject.UIButton.PressedColor = Color.Red

DisabledColor​

SColor DisabledColor {get; set; }

The color of the control when it is disabled.

示例

Lua
Space.Host.ExecutingObject.UIButton.PressedColor = Color.Red

ColorMultiplier​

float ColorMultiplier {get; set; }

This multiplies the tint color for each transition by its value. With this you can create colors greater than 1 to brighten the colors on graphic elements whose base color is less than white.

示例

Lua
Space.Host.ExecutingObject.UIButton.ColorMultiplier = Color.Red

GameObject只读​

SGameObject GameObject {get; }

示例

Lua
Space.Host.ExecutingObject.UIButton.GameObject = Color.Red