Save Object

CarterGames.SaveManager.Runtime
CarterGames.Assets.SaveManager

A save object defines a scriptable object class that holds save values to save data in your game. Each object can have as many values as you’d like and is designed to be modular to an extend. You can create multiple save objects of the same type if you need it, but you will need to define seperate save keys for these variants to distinguish them.

API

Fields

[SerializeField] private bool
Is used internally for the custom inspector for the object to hold if the object dropdown is expanded or not.

[SerializeField] private string
Defines the save key for the save object. If you want to use multiple of the same type, you will need to make sure this is unique for each variant otherwise there will be issues.

Properties

public bool
Gets if the save object is initialized by checking that the save key is not empty.

public string
Gets the save key defined for this save object.

public Dictionary<string, SaveValueBase>
Holds a lookup of all the save values this save object stores at runtime.

Methods

public virtual void
Saves the values on the save object & applies them to the save file.

playerSaveObject.Save();

public virtual void
Loads the save object when called. You shouldn’t need to call this manually as the system does it automatically, but it is there if you require to load it manually.

playerSaveObject.Load();

Resets all the save values on the save object to their value defaults.

playerSaveObject.ResetObjectSaveValues();

Gets the savable value for the save object’s save values. Used in the save managers save method.

SerializableDictionary<string, SaveValueBase> data = playerSaveObject.GetSaveValue();

public bool
Gets if there is a save value of the requested key.

bool HasSaveValue = playerSaveObject.HasValue("playerNameSaveKey");

public SaveValue<T>
Gets the save value of the key entered.

string value = playerSaveObject.GetValue<string>("playerNameSaveKey");

public void
Sets the value to the value entered.

playerSaveObject.SetValue("playerNameSaveKey", "John Smith");

public void
Resets a value with the corresponding key.

playerSaveObject.ResetElement("playerNameSaveKey");