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);