wiki.sine.space | sinespace

Scripting/SUIButton

From wiki.sine.space
Revision as of 05:51, 13 October 2021 by Voidtech (Talk | contribs)

Jump to: navigation, search

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.


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.