-
Notifications
You must be signed in to change notification settings - Fork 3
SaveManager_ClassAPI
CG-Tespy edited this page Apr 26, 2020
·
2 revisions
The class that mainly handles saving, loading, and erasing save data.
Inherits from: MonoBehaviour
Namespace: CGTUnity.Fungus.SaveSystem
protected SaveWriter saveWriter
- Reference to the SaveWriter ScriptableObject the manager uses to write save data.
- Reference to the SaveWriter ScriptableObject the manager uses to read save data from disk as GameSaveData objects.
- The GameLoader in the scene.
- The GameSaver in the scene.
- Whether or not this should display warnings when asked to add saves when it isn't allowed to.
- Whether or not this SaveManager is allowed to write or register new save data.
- SaveManagers on Awake disallow themselves from doing any save-writing/registration. This decides how long they do so, before reallowing themselves (assuming savingEnabled was equal to true at the time).
virtual bool SavingEnabled { get; set; }
virtual float AwakeSaveDelay { get; set; }
virtual SaveReader SaveReader { get; }
virtual string SaveDirectory { get; }
- Where on disk the save data gets written to.
virtual bool AddSave(SaveSlot slot, bool writeToDisk = true)
- Creates and registers new save data with the passed slot's number, then writing it to disk if set to do so. Save replacement may happen depending on the aforementioned number.
- Creates and registers new save data with the passed slot number, then writing it to disk if set to do so. Save replacement may happen depending on the aforementioned number.
- Adds a save to this manager. If the passed save shares a number with one it's already keeping track of, the old one is replaced with the new one. In which case, the new one will be written to disk regardless of the second argument.
virtual bool LoadSave(int slotNumber)
- Loads a save with the passed slot number. Returns true if successful, false otherwise.
- Loads the save data assigned to the passed slot. Returns true if successful, false otherwise.
- Loads the passed GameSaveData, regardless of whether this manager is keeping track of it or not.
virtual GameSaveData GetSave(int slotNumber)
- Returns the save that has the passed slot number, if it exists. Returns null if it doesn't.
- If you want a slotless save system in your game, you can just have an instance of this in each of your scenes without any accompanying SaveSlot or SaveSlotManager objects. You can use Invoke Event and Invoke Method commands to access the public parts of the API outlined above.
- The system still treats everything as slot-based under the hood, since you'd have to provide slot numbers for the save-writing-and-loading functions. That's just a small detail, however; your system will still look to the player like it's slotless.