Player data kept between visits

PlayerData keeps values for the local player, for your world, from one visit to the next: a language chosen, a volume, a best score. They stay on the player's computer or headset, one small file per world and per NodeWorld account.

csharp
using NodeWorld.Flux;

namespace MyWorld
{
    [ClientOnly]
    public class MusicVolume : FluxScript
    {
        public AudioSource music;
        public Slider volume;

        protected override void Start()
        {
            if (PlayerData.TryGetFloat("volume", out var saved)) volume.SetValueWithoutNotify(saved);
            music.volume = volume.value;
            volume.onValueChanged.AddListener(value =>
            {
                music.volume = value;
                PlayerData.SetFloat("volume", value);
            });
        }
    }
}
SetInt, SetFloat, SetBool, SetStringKeep a value under a key; written to the file when it changes.
TryGetInt, TryGetFloat, TryGetBooltrue and the value when the key holds a value of that kind; false otherwise. There is no method that reads a string back.
Delete(key)Forgets a key.

Limits

  • 256 keys per world and per player, keys of 1 to 128 characters, string values of 4 096 characters at most. Past these, the call is refused: PlayerData: a world keeps at most 256 values per player.
  • A key has no line break.
  • The values are the player's, on their device: another player's game does not see them, and the server has none. For values every player shares, use the synced state.
  • They stay on the device the player played on: on another computer or headset, the world starts without them.
  • In Play mode, they are kept for the Play Mode Account Id of the NW World Config.