Save Manager

CarterGames.SaveManager.Runtime
CarterGames.Assets.SaveManager

The save manager is the main class you’ll use to save & load your game in code. You can also use the class to get save objects via code instead of needing a reference to them directly.

API

Properties

Bool

Gets if the save manager is initialized or not.

Bool

Gets if the game is currently saving or not.

Events

Evt

Listen to, to get callbacks when the game has been saved.

SaveManager.Saved.Add(MyMethod);

Bool

Listen to, to get callbacks when the game has been loaded.

SaveManager.Loaded.Add(MyMethod);

Methods

Method
SaveObject → The save object to register.

Registers a save object with the save manager. It is called automatically by the save manager.

SaveManager.RegisterObject(MySaveObject);

Method
bool → Optional → Calls any save listeners. Default: True

Saves the game when called.

SaveManager.Save();

Method

Loads the game when called

SaveManager.Load();

Method

Clears the save data when called.

SaveManager.Clear();

Method

Returns
T → The save object found of the requested type.

Gets the first save object of the requested save object type. The type must inherit from the save object class to be found by this method.

MySaveObject obj = SaveManager.GetSaveObject<MySaveObject>();

Method
string → The save key for the object to get.

Returns
T → The save object found of the requested type.

Gets the first save object of the requested save object type which has the matching save key. The type must inherit from the save object class to be found by this method.

MySaveObject obj = SaveManager.GetSaveObject<MySaveObject>("MySaveObjectKey");

Method

Returns
T → The save object found of the requested type.
bool → If a save object was found.
out T → The save object found.

Tries to get the first save object of the requested save object type. The type must inherit from the save object class to be found by this method.

bool hasObject = SaveManager.TryGetSaveObject<MySaveObject>(out MySaveObject obj);

Method
string → The save key for the object to get.

Returns
T → The save object found of the requested type.
bool → If a save object was found.
out T → The save object found.

Tries to get the first save object of the requested save object type which has the matching save key. The type must inherit from the save object class to be found by this method.

bool hasObject = SaveManager.TryGetSaveObject<MySaveObject>("MySaveObjectKey", out MySaveObject obj);