Toggle
namespace Griff.Scenes;
public sealed class Toggle : ComponentTurns a Button into a switch: each click flips IsOn, and its label can say which way it’s set (“Sound: On”). Set Setting to turn the sound or fullscreen on and off with no code, remembered next time. Needs a Button on the same entity.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”public bool IsOn { get; set; }Whether it’s on now; each click flips it.
OffText
Section titled “OffText”public string? OffText { get; set; }What the entity’s Text says while it’s off, e.g. “Sound: Off”.
OnText
Section titled “OnText”public string? OnText { get; set; }What the entity’s Text says while it’s on, e.g. “Sound: On”. Empty leaves the text alone.
SaveAs
Section titled “SaveAs”public string? SaveAs { get; set; }A name to keep it under in Game.SaveData, e.g. “screenShake”; read it with GetBool.
Setting
Section titled “Setting”public GameSetting Setting { get; set; }A setting of the game it switches: Sound, Fullscreen or VSync. While set, the toggle always shows that setting.
Events
Section titled “Events”Changed
Section titled “Changed”public event Action<Toggle>? ChangedRaised when the player flips it.