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 IsInitialized
Bool
Gets if the save manager is initialized or not.
bool IsSaving
Bool
Gets if the game is currently saving or not.
Events
Evt Saved
Evt
Listen to, to get callbacks when the game has been saved.
SaveManager.Saved.Add(MyMethod);
Evt Loaded
Bool
Listen to, to get callbacks when the game has been loaded.
SaveManager.Loaded.Add(MyMethod);
Methods
void RegisterObject(SaveObject obj)
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);
void Save()
Method
bool
ā Optional ā Calls any save listeners. Default: True
Saves the game when called.
SaveManager.Save();
void Load()
Method
Loads the game when called
SaveManager.Load();
void Clear()
Method
Clears the save data when called.
SaveManager.Clear();
SaveObject<T> GetSaveObject()
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");
bool TryGetSaveObject(SaveObject<T> obj)
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);