Save Value

CarterGames.SaveManager.Runtime
CarterGames.Assets.SaveManager

The save value class defines a value that is saved. It’s in the name. This inherits from an abstract base class that holds a non-type object as the value. While the generic class which you’ll be using can be any type. However the type you are saving has to be serializable already. You can serialize a dictionary with the serialized dictionary class provided with the asset should you wish.

You can define a save value in any save object inheriting class. Fields will need to be either [SerializeField] or public to be visible in the inspector & save editor window. They can be defined in a few ways:

// A string save value with a randomly generated save key.
[SerializeField] private SaveValue<string> playerName;

// A string save value with a manually defined save key.
[SerializeField] private SaveValue<string> playerName = new SaveValue<string>("playerNameSaveKey");

// A string save value with a manually defined save key & default value defined.
[SerializeField] private SaveValue<string> playerName = new SaveValue<string>("playerNameSaveKey", "John Smith");

API

Fields

T value

Properties

T Value

object ValueObject

Constructors

SaveValue<T>()

SaveValue<T>(string saveKey)

SaveValue<T>(string saveKey, T value)

Methods

void ResetValue()