Class ToggleUtils
Utilities for subscribing to and managing Toggle value change events in a cross-compatible way between Mono and IL2CPP. Handles Unity versions where Toggle.onValueChanged is exposed as either a field or a property. This class is intended for public use by mod developers.
public static class ToggleUtils
- Inheritance
-
ToggleUtils
- Inherited Members
Methods
AddListener(Toggle, Action<bool>)
Adds a listener to a Toggle's onValueChanged event in an IL2CPP-safe manner.
public static void AddListener(Toggle toggle, Action<bool> listener)
Parameters
ClearListeners(Toggle)
Removes all listeners from a Toggle's onValueChanged event.
public static void ClearListeners(Toggle toggle)
Parameters
toggleToggle
GetGraphic(Toggle)
Gets the Toggle's checkmark graphic in a version-agnostic manner.
public static Graphic? GetGraphic(Toggle toggle)
Parameters
toggleToggle
Returns
- Graphic
RemoveListener(Toggle, Action<bool>)
Removes a previously added listener from a Toggle's onValueChanged event.
public static void RemoveListener(Toggle toggle, Action<bool> listener)
Parameters
SetGraphic(Toggle, Graphic)
Sets the Toggle's checkmark graphic in a version-agnostic manner (field or property).
public static void SetGraphic(Toggle toggle, Graphic graphic)
Parameters
toggleTogglegraphicGraphic