World Utilities / Values

Float

A floating point number - volume, brightness, intensity and everything else on a slider.

since v0.1.0localsynchronizedpersistednetworked
Component Add Component menu / prefab Source
Local FloatVRCTools.World.LocalValues.LocalFloat Local Values › Local Floatprefab: Local Float.prefab LocalFloat.cs ↗
Synchronized FloatVRCTools.World.SynchronizedValues.SynchronizedFloat Synchronized Values › Synchronized Floatprefab: Synchronized Float.prefab SynchronizedFloat.cs ↗
Persisted FloatVRCTools.World.PersistedValues.PersistedFloat Persisted Values › Persisted Floatprefab: Persisted Float.prefab PersistedFloat.cs ↗

Float values are typically driven by a Slider, displayed with a Label and applied to materials or animators.

Parameters

Parameter Default Description
Default Value 0 The state the value is initialized with.
Restrict Value false Clamp the state between Minimum Value and Maximum Value.
Minimum Value 0 Lower bound when restricted.
Maximum Value 1 Upper bound when restricted.
Prevent Nuisance Updates false Ignore changes smaller than Minimal Update Difference.
Minimal Update Difference Mathf.Epsilon Smallest change that is propagated when nuisance updates are prevented.
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.

Restrictions

When Minimum Value exceeds Maximum Value, the restriction is disabled at runtime and an error is logged. Restricting a value also enables mapping on sliders and labels, which translate the restricted range into a display range (e.g. 0..1 shown as 0..100%).

As of v0.7.0, persisted floats do not apply Restrict Value when their state changes; only the inspector shows the restriction settings. Clamp the value before assigning it, or restrict the UI that writes to it (e.g. the slider’s min/max).

Nuisance updates

Without Prevent Nuisance Updates, every assignment emits EVENT_STATE_UPDATED - even when the new number equals the old one. Sliders write on every frame they are dragged, so for synchronized floats this would mean a network update per frame. Enable the option and pick a sensible Minimal Update Difference (e.g. 0.001 for a 0..1 volume) to keep traffic and work down.

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
_Zero() all Sets the state to 0.
_Reset() local, persisted Restores Default Value.