World Utilities / Values

Boolean

An on/off value - the workhorse behind toggles, feature switches and material swaps.

since v0.1.0localsynchronizedpersistednetworked
Component Add Component menu / prefab Source
Local BooleanVRCTools.World.LocalValues.LocalBoolean Local Values › Local Booleanprefab: Local Boolean.prefab LocalBoolean.cs ↗
Synchronized BooleanVRCTools.World.SynchronizedValues.SynchronizedBoolean Synchronized Values › Synchronized Booleanprefab: Synchronized Boolean.prefab SynchronizedBoolean.cs ↗
Persisted BooleanVRCTools.World.PersistedValues.PersistedBoolean Persisted Values › Persisted Booleanprefab: Persisted Boolean.prefab PersistedBoolean.cs ↗

A boolean value stores true or false. It is most commonly connected to an Object Toggle or Material Swap applicator and controlled by a Toggle or Toggle Button.

Parameters

Parameter Default Description
Default Value false The state the value is initialized with.
Key (persisted only)   PlayerData key used to store the value. Required - see choosing keys.

Synchronized variants additionally expose the networking settings.

Networked values need a unique hierarchy path - see naming networked objects.

Events

Event Kinds Description
EVENT_STATE_UPDATED all The state changed (also emitted once with the initial state).
EVENT_STATE_RESET local, persisted _Reset() restored the default value.
EVENT_LOADED persisted Stored data has been restored - see loading.
EVENT_PERSIST persisted The state has been written to player data.

Functions

Function Kinds Description
_SetTrue() all Sets the state to true.
_SetFalse() all Sets the state to false.
_Toggle() all Inverts the state.
_Reset() local, persisted Restores Default Value.

Usage

Need a mirror toggle that remembers the player’s choice?

  1. Drag the Persisted Boolean prefab into your scene and give it a key such as settings.mirror.
  2. Add an Object Toggle Applicator, set Type to LOCAL, reference the persisted boolean and add the mirror object to Targets.
  3. Add a Toggle Button to your menu and reference the same value.

To combine several booleans (for example owner allows it and player wants it), use a Boolean Operation converter. To run your own logic when the state flips, use a Boolean Event Applicator.