Skip to main content

MenuToggleSetting

A class in Root.Township, Alta.Menu.

Client menu control for an on/off setting, driven by a selection lever. Colours its label and fires events when turned on or off.

Constructors​

MemberWhat it is
MenuToggleSetting()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private bool isSelectedWhether the toggle is currently on.
private SelectionLever leverThe selection lever the player moves.
private AltaEvent onDeselectedEvent fired when the toggle turns off.
private AltaEvent onSelectedEvent fired when the toggle turns on.
private int selectedIndexThe lever position that means on. Default 1.

Methods​

MemberWhat it is
protected override void OnValidate()Editor: names the object after the setting, or logs if no setting is set.
protected override void Setup()Reads the setting's value and moves the lever to match.
3 private and internal methods
MemberWhat it is
private void Awake()Listens for the lever's selection changes.
private void Select(bool isSelected)Sets the label to the on or off colour from MenuSettings and fires onSelected or onDeselected.
private void ToggleSelection(SelectionLever arg1, int arg2, int arg3)When the lever moves, turns the setting on if it is at selectedIndex, off otherwise, and saves it.