Editing Mod API Reference:UI
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
Mods can put UI (user interface) onto the screen when called from one of the Client '''Present''' [[Mod Hooks|hooks]]. This page describes how to create and update UI elements. | Mods can put UI (user interface) onto the screen when called from one of the Client '''Present''' [[Mod Hooks|hooks]]. This page describes how to create and update UI elements. | ||
− | UI elements are created by accessing the <code>UI</code> global. For example, mods can call UI.CreateButton(...) to create a button | + | UI elements are created by accessing the <code>UI</code> global. For example, mods can call UI.CreateButton(...) to create a button. |
Behind the scenes, these objects are implemented using Unity's UI and layout system. Being familiar with Unity's UI system will make understanding how to build UI easier, but it's not a requirement. | Behind the scenes, these objects are implemented using Unity's UI and layout system. Being familiar with Unity's UI system will make understanding how to build UI easier, but it's not a requirement. | ||
Line 53: | Line 53: | ||
'''Button''': A button that players can click on to do something. | '''Button''': A button that players can click on to do something. | ||
* '''Text''' ''string'': The text to display on the button. | * '''Text''' ''string'': The text to display on the button. | ||
− | * '''Color''' ''string'': The color of the button. Pass this as a string in #RRGGBB format. | + | * '''Color''' ''string'': The color of the button. Pass this as a string in #RRGGBB format. |
− | + | * '''TextColor''' ''string'': The color of the text on teh button. Pass this as a string in #RRGGBB format. | |
− | * '''TextColor''' ''string'': The color of the text on | + | |
* '''OnClick''' ''function'': Pass the name of a lua function to be called whenever the player clicks the button. | * '''OnClick''' ''function'': Pass the name of a lua function to be called whenever the player clicks the button. | ||
* '''Interactable''' ''bool'': If false, the control will be grayed out and unusable by the player. | * '''Interactable''' ''bool'': If false, the control will be grayed out and unusable by the player. | ||
Line 82: | Line 81: | ||
* '''SliderPreferredWidth''' ''number'': Allows setting the preferred width of just the slider. See '''Common Properties''' above. | * '''SliderPreferredWidth''' ''number'': Allows setting the preferred width of just the slider. See '''Common Properties''' above. | ||
* '''Interactable''' ''bool'': If false, the control will be grayed out and unusable by the player. | * '''Interactable''' ''bool'': If false, the control will be grayed out and unusable by the player. | ||
+ | |||
== Helper Functions == | == Helper Functions == | ||
Line 88: | Line 88: | ||
− | + | '''UI.Alert''': Pops up a dialog with a message and an Okay button to close the message. Call this as simply <code>UI.Alert(msg)</code> | |
− | + | ||
− | + | ||
− | '''UI.Alert''': Pops up a dialog with a message and an Okay button to close the message. Call this as simply <code>UI.Alert(msg)</code> | + | |
Line 97: | Line 94: | ||
* '''Message''' ''string'': Text to appear at the top of the dialog. | * '''Message''' ''string'': Text to appear at the top of the dialog. | ||
* '''Options''' ''array'': A list of options, each of which will show up as a button. Each entry in this array should be a table with two fields, '''text''' and '''selected'''. '''text''' populates the text that will appear on that button, and '''selected''' is a zero-argument function that gets called if the player selects that option. | * '''Options''' ''array'': A list of options, each of which will show up as a button. Each entry in this array should be a table with two fields, '''text''' and '''selected'''. '''text''' populates the text that will appear on that button, and '''selected''' is a zero-argument function that gets called if the player selects that option. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:Mod API Reference]] | [[Category:Mod API Reference]] |