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
| Member | What it is |
|---|
MenuToggleSetting() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|
private bool isSelected | Whether the toggle is currently on. |
private SelectionLever lever | The selection lever the player moves. |
private AltaEvent onDeselected | Event fired when the toggle turns off. |
private AltaEvent onSelected | Event fired when the toggle turns on. |
private int selectedIndex | The lever position that means on. Default 1. |
Methods
| Member | What 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
| Member | What 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. |