wiki.sine.space | sinespace

Difference between revisions of "Scripting/SUIButton"

From wiki.sine.space
Jump to: navigation, search
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suibutton")
 
Line 1: Line 1:
A control that executes code in response to user interactions.
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suibutton
 
+
=Members=
+
 
+
{{ScriptFunction|void|OnClick|(Closure callback);|Invoke when a user clicks the button and releases it.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
function Click()<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;button.OnClick(function ()<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Space.Log("Hello Lua!")<br>
+
&nbsp;&nbsp;&nbsp;&nbsp;button.end)
+
end
+
}}
+
 
+
=Properties=
+
 
+
{{ScriptFunction|bool|Enabled|{get; set;}|Whether the button component is Enabled or not.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.Enabled)<br>
+
''--return true.''|6=<pre>--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)</pre>
+
}}
+
 
+
{{ScriptFunction|bool|Interactable|{get; set;}|Enable Interactable if you want this button to accept input.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.Interactable)<br>
+
''--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>
+
}}
+
 
+
{{ScriptFunction|SColor|NormalColor|{get; set;}|The normal color of the control.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.NormalColor)
+
}}
+
 
+
{{ScriptFunction|SColor|HighlightedColor|{get; set;}|The color of the control when it is highlighted.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.HighlightedColor)
+
}}
+
 
+
{{ScriptFunction|SColor|PressedColor|{get; set;}|The color of the control when it is pressed.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.PressedColor)
+
}}
+
 
+
{{ScriptFunction|SColor|DisabledColor|{get; set;}|The color of the control when it is disabled.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.DisabledColor)
+
}}
+
 
+
{{ScriptFunction|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.|5=local button=Space.Host.GetReference("Button").UIButton<br>
+
''--add Button to object references.''<br>
+
Space.Log(button.ColorMultiplier)<br>
+
''--print 1.''
+
}}
+
 
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 06:28, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suibutton