Table of Contents

Class ToggleUtils

Namespace
S1API.Utils
Assembly
S1API.dll

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

toggle Toggle
listener Action<bool>

ClearListeners(Toggle)

Removes all listeners from a Toggle's onValueChanged event.

public static void ClearListeners(Toggle toggle)

Parameters

toggle Toggle

GetGraphic(Toggle)

Gets the Toggle's checkmark graphic in a version-agnostic manner.

public static Graphic? GetGraphic(Toggle toggle)

Parameters

toggle Toggle

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

toggle Toggle
listener Action<bool>

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

toggle Toggle
graphic Graphic