Class ButtonUtils
Utility helpers for managing Unity UI UnityEngine.UI.Buttons. This class is intended for public use by mod developers.
public static class ButtonUtils
- Inheritance
-
ButtonUtils
- Inherited Members
Methods
AddListener(Button, Action)
Adds a click listener to the specified button, ensuring compatibility with IL2CPP and Mono.
public static void AddListener(Button button, Action action)
Parameters
buttonButtonactionAction
ClearListeners(Button)
Removes all listeners from the specified button safely.
public static void ClearListeners(Button button)
Parameters
buttonButton
Disable(Button, Text?, string?)
Disables the button and optionally updates the label.
public static void Disable(Button button, Text? label = null, string? text = null)
Parameters
buttonButtonlabelTexttextstring
Enable(Button, Text?, string?)
Enables the button and optionally updates the label.
public static void Enable(Button button, Text? label = null, string? text = null)
Parameters
buttonButtonlabelTexttextstring
RemoveListener(Button, Action)
Removes a previously added click listener from the specified button.
public static void RemoveListener(Button button, Action action)
Parameters
buttonButtonactionAction
SetLabel(Text, string)
Sets the label text of a button with a known Text child.
public static void SetLabel(Text label, string text)
Parameters
labelTexttextstring
SetStyle(Button, Text, string, Color)
Sets the button label and background color.
public static void SetStyle(Button button, Text label, string text, Color bg)
Parameters
buttonButtonlabelTexttextstringbgColor