Skip to content

Toggle

Turns 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.

Requires: Button

In a network game, each machine keeps its own entity with this on it: it isn’t sent.

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • isOn: true or false = true. Whether it’s on now; each click flips it. (Field: on or off.)
  • setting: one of None, Volume, MusicVolume, SoundVolume, Sound, Fullscreen, Skip, Auto, SkipUnread, AutoSpeed, AudioOffset, VisualOffset, NoteSpeed, WindowSize, VSync, FrameCap, UiScale, EdgeScroll, PanSpeed = “None”. A setting of the game it switches: Sound, Fullscreen or VSync. While set, the toggle always shows that setting. (Field: one of its values.)
  • saveAs: text = null. A name to keep it under in Game.SaveData, e.g. “screenShake”; read it with GetBool. (Names a name in the save data: this entity’s own, which other fields can name.) (Field: a name.)
  • onText: text = null. What the entity’s Text says while it’s on, e.g. “Sound: On”. Empty leaves the text alone. (Plain text: words its text shows while it’s on.) (Field: text.)
  • offText: text = null. What the entity’s Text says while it’s off, e.g. “Sound: Off”. (Plain text: words its text shows while it’s off.) (Field: text.)

Scripts use it as Toggle: its methods, events and values that aren’t saved with the scene.