All input elements allow for the XML UI to interact with the Lua scripts in the game instance.
Tip
Be sure to check out the UI section of the Lua Scripting API for how to receive the input from these element types. With Lua scripting, you can even modify the UI elements!
When using an attribute that triggers scripting, like onValueChanged or onClick, the UI will target a default location. Global UI targets Global script, Object UI targets the Object's script. This behavior can be overwritten. For example:
<ButtononClick="uiClickFunc">Click Me</Button>
If this was in the Global UI, this would trigger a function in the Global Lua script function uiClickFunc(). But if you want to target a function on an Object's script? Place the GUID for the object before the function name, like so:
Now when the button is clicked, it will still try to activate function uiClickFunc() but it will try to do so on the Object Lua script of the Object with the GUID of "aaa111".
When clicked, a Lua function with this name will be triggered.
string
(none)
interactable
true
colors
#FFFFFF|#FFFFFF|#C8C8C8|rgba(0.78,0.78,0.78,0.5)
textShadow
(none)
textOutline
(none)
textAlignment
UpperLeft
UpperCenter
UpperRight
MiddleLeft
MiddleCenter
MiddleRight
LowerLeft
LowerCenter
LowerRight
UpperLeft
icon
string
(none)
iconWidth
float
iconColor
iconAlignment
Left
Right
Left
padding
float float float float
0 0 0 0
transition
None
ColorTint
SpriteSwap
Animation
ColorTint
highlightedSprite
string
pressedSprite
string
disabledSprite
string
Example:
<!-- Standard Button --><Button>Button Text</Button><!-- Button with Icon --><Buttonicon="SomeName"/><!-- Button with Icon and Text --><Buttonicon="SomeName">Button With Icon</Button>
Tip
onClick passes nil for the value by default. However, you can assign a string that will be passed in onClick.
<ButtononClick="clickFunction(stringName)"/>
The above example passes a string with the name of "stringName" to the Lua function for the value property.