Save System
Save System Overview
The save system allows storing objects instead of simple values.
Each entry in the save database consists of a unique string key and a value object that implements the ISave interface.
Creating a New Save Class
For example, let’s track how many enemies the player has defeated.
Create a new class that implements ISave:
public class DefeatedEnemiesCounterSave : ISave
{
public int defeatedEnemiesCount;
public void Flush()
{
// Called before saving, for cleanup or data processing
}
}Accessing Save Data
When the player starts a stage, get the save instance via SaveManager:
var save = GameController.SaveManager
.GetSave<DefeatedEnemiesCounterSave>("Defeated Enemies Counter");The Save Manager will:
Search its database for an entry with the key
"Defeated Enemies Counter".If found - return the existing instance.
If not found - create a new one, store it in the database, and return it.
Updating the Data
Each time an enemy is defeated, increase the counter:
You can then update the UI manually, for example:
Alternatively, the UI can fetch the same save instance and subscribe to its updates.
Save Complexity
ISave instances can be as simple or complex as needed.
You can use properties and events to notify the UI or other systems when a value changes.
The Flush() method can also be used for cleanup if needed.
Example:
Once created, the SaveManager automatically stores and saves the instance -
you do not need to manually notify it of value changes.
Save Manager
The Save Manager is located in the Main Menu Scene under the Game Controller GameObject. It behaves as a singleton - one instance persists for the entire game session.
Save Manager Inspector
Save Manager component includes the following fields:

Save Type - Enum that determines whether to use a dedicated save file or Unity
PlayerPrefs.Clear Save - If
true, the save data is reset on game start. Useful for testing.Auto Save Enabled - If
true, enables automatic saving via coroutine.Auto Save Delay - Interval (in seconds) between automatic saves.
Last updated