Table of Contents

Class ButtonUtils

Namespace
S1API.Utils
Assembly
S1API.dll

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

button Button
action Action

ClearListeners(Button)

Removes all listeners from the specified button safely.

public static void ClearListeners(Button button)

Parameters

button Button

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

button Button
label Text
text string

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

button Button
label Text
text string

RemoveListener(Button, Action)

Removes a previously added click listener from the specified button.

public static void RemoveListener(Button button, Action action)

Parameters

button Button
action Action

SetLabel(Text, string)

Sets the label text of a button with a known Text child.

public static void SetLabel(Text label, string text)

Parameters

label Text
text string

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

button Button
label Text
text string
bg Color