Skip to content

UI

Functions

AddMenuButton

 function UI.AddMenuButton((string)Text , (function)Callback, (optional parameters)Callback parameters)
Parameter Type 📝 Description
Text string Text to show on the button
Callback function Function to call back when this button is pressed
Callback parameters optional parameters Any number of parameters can be passed after the callback function and they will be sent in the callback when the button is pressed.

UI.AddMenuButton

Adds a button to the pause menu. Make sure to only do this in a function that is being called back from the Messager.StartGameUI listener. If you do this straight OnTemplate it will fail as the pause menu doesn't exist yet at that point.

Example
UI.AddMenuButton("Button", Callback)

GetSprite

 function UI.GetSprite((string)Sprite name)
Parameter Type 📝 Description
Sprite name string Filename without extension of the desired Sprite

UI.GetSprite

Returns a sprite with the desired filename without extension. To get your own sprites this way place them as .png files in the 'sprites' folder or the 'icons' folder of your mod.

Example

UI.GetSprite("missing")
This will find a sprite with name 'missing', which happens to be the question mark icon.


AddBlueButton

 function UI.AddBlueButton((RectTransform)Parent , (string)Text, (string)Tag, (function)Callback, (optional parameters)Callback parameters)
Parameter Type 📝 Description
Parent RectTransform Parent of the new button.
Text string Text to show on the button
Tag string Tag that can be used to retrieve this button later.
Callback function Function to call back when this button is pressed
Callback parameters optional parameters Any number of parameters can be passed after the callback function and they will be sent in the callback when the button is pressed.

UI.AddBlueButton

Adds a blue button to a parent RectTransform with a tag that can be used to retrieve it later.

Example
UI.AddBlueButton(rect,"Button", "buttons", Callback)

AddCloseButton

 function UI.AddCloseButton((RectTransform)Parent , (string)Text, (string)Tag, (function)Callback, (optional parameters)Callback parameters)
Parameter Type 📝 Description
Parent RectTransform Parent of the new button.
Text string Text to show on the button
Tag string Tag that can be used to retrieve this button later.
Callback function Function to call back when this button is pressed
Callback parameters optional parameters Any number of parameters can be passed after the callback function and they will be sent in the callback when the button is pressed.

UI.AddCloseButton

Adds a red close button to a parent RectTransform with a tag that can be used to retrieve it later.

Example
UI.AddCloseButton(rect,"Button", "buttons", Callback)

DeleteWithTag

 function UI.DeleteWithTag((string)Tag)
Parameter Type 📝 Description
Tag string Tag to delete

UI.DeleteWithTag

Deletes all UI elements found with the specified tag

Example

UI.DeleteWithTag("trophy")
This example deletes all elements with the tag 'trophy'


NewColor

 function UI.NewColor((float)Red , (float)Green, (float)Blue, (float)Alpha)
Parameter Type 📝 Description
Red float Red Value decimal between 0 and 1
Green float Green Value decimal between 0 and 1
Blue float Blue Value decimal between 0 and 1
Alpha float Alpha Value decimal between 0 and 1

UI.NewColor

Returns a color with the desired parameters.

Example

UI.NewColor(1,1,1,1)
This returns a white color with full alpha


ColorFromHex

 function UI.ColorFromHex((string)Hex color)
Parameter Type 📝 Description
Hex color string Hex code for a color

UI.ColorFromHex

Returns a color with the desired hex code.

Example

UI.ColorFromHex(#fff)
This returns a white color


ShowCornerNotification

 function UI.ShowCornerNotification((string) text)

UI.ShowCornerNotification

Shows a corner notification


ShowTopNotification

 function UI.ShowTopNotification((string) text)

UI.ShowTopNotification

Shows a top notification


ReceiveChatMessage

 function UI.ReceiveChatMessage((string) text)

UI.ReceiveChatMessage

Adds a string to the chat messages like it was a message. It will show up without a user name associated with it like a server message. If you came to this method looking to get callbacks with messages other players sent you might want to look into Messager.AnyChatMessage


FormatText

 function UI.FormatText((string)Text , Parameters)
Parameter Type 📝 Description
Text string Text to use
Parameters objects to use

UI.FormatText

Use this if you need to insert the value of an object, variable, or expression into another string. It works like String.Format() in C#

Example

UI.FormatText("This is {0}","awesome")
This example will return 'This is awesome'


ClearListSelectorButtonInfo

 function UI.ClearListSelectorButtonInfo()

UI.ClearListSelectorButtonInfo

Clears the ListSelectorHelper button infos

Example
UI.ClearListSelectorButtonInfo()

OpenSliderSelector

 function UI.OpenSliderSelector((string)Text , (bool)Slider with whole numbers only?, (float)Default Value, (float)Min Value, (float)Max Value, (function)Callback)
Parameter Type 📝 Description
Text string Text to show on the button
Slider with whole numbers only? bool True if it should only have whole numbers, no decimals.
Default Value float Default Slider Value
Min Value float Minimum Slider Value
Max Value float Maximum Slider Value
Callback function Function to call back when this button is pressed
Callback parameters optional parameters Any number of parameters can be passed after the callback function and they will be sent in the callback when the button is pressed.

UI.OpenSliderSelector

Adds button data to the pause menu. Make sure to only do this in a function that is being called back from the Messager.StartGameUI listener. If you do this straight OnTemplate it will fail as the pause menu doesn't exist yet at that point.

Example
UI.OpenSliderSelector("Button Text", true,0,0,1, Callback)

GetLastSliderSelectorResult

 function UI.GetLastSliderSelectorResult()

UI.GetLastSliderSelectorResult

Returns a float with the result of the last slider selector.

Example
UI.GetLastSliderSelectorResult()

AddListSelectorButton

 function UI.AddListSelectorButton((string)Text , (bool)Should Close After Click?, (function)Callback, (optional parameters)Callback parameters)
Parameter Type 📝 Description
Text string Text to show on the button
Should Close After Click? bool True if it should close the selector after being clicked.
Callback function Function to call back when this button is pressed
Callback parameters optional parameters Any number of parameters can be passed after the callback function and they will be sent in the callback when the button is pressed.

UI.AddListSelectorButton

Adds button data to the list selector menu. Used to populate the list selector menu with data before opening it with UI.OpenListSelector()

Example
UI.AddListSelectorButton("Button Text", true, Callback)

OpenListSelector

 function UI.OpenListSelector()

UI.OpenListSelector

Opens the List Selector

Example
UI.OpenListSelector()

CloseListSelector

 function UI.CloseListSelector()

UI.CloseListSelector

Closes the List Selector

Example
UI.CloseListSelector()

ClearInteractUIs

 function UI.ClearInteractUIs()

UI.ClearInteractUIs

Clears the interact UIs

Example
UI.ClearInteractUIs()

Comments