wiki.sine.space | sinespace

Difference between revisions of "Scripting/SUIButton"

From wiki.sine.space
Jump to: navigation, search
Line 36: Line 36:
 
''--add Button to object references.''<br>
 
''--add Button to object references.''<br>
 
Space.Log(button.Interactable)<br>
 
Space.Log(button.Interactable)<br>
''--return true.''
+
''--return true.''|6=<pre>--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)</pre>
 
}}
 
}}
  

Revision as of 05:55, 13 October 2021

A control that executes code in response to user interactions.

Members

OnClick

void OnClick (Closure callback);

Invoke when a user clicks the button and releases it.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.
function Click()
    button.OnClick(function ()
        Space.Log("Hello Lua!")
    button.end)

end


Properties

Enabled

bool Enabled {get; set;}

Whether the button component is Enabled or not.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.
Space.Log(button.Enabled)

--return true.


--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.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.
Space.Log(button.Interactable)

--return true.


--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.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.

Space.Log(button.NormalColor)


HighlightedColor

SColor HighlightedColor {get; set;}

The color of the control when it is highlighted.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.

Space.Log(button.HighlightedColor)


PressedColor

SColor PressedColor {get; set;}

The color of the control when it is pressed.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.

Space.Log(button.PressedColor)


DisabledColor

SColor DisabledColor {get; set;}

The color of the control when it is disabled.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.

Space.Log(button.DisabledColor)


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.

local button=Space.Host.GetReference("Button").UIButton

--add Button to object references.
Space.Log(button.ColorMultiplier)

--print 1.