Save & Load Add-On
  • Welcome to Save & Load Add-On for FPS Engine!
  • BEFORE WE START
    • Early Considerations
    • Add-On Compatibility
    • List of Tutorials
  • GETTING STARTED
    • 01. Basic Set-Up
    • 02. Roadmap
  • CONTENT
    • 03. Content
      • 03.1 DataPersistence
        • DataPersistence_SO
        • DataPersistenceManager
        • FileDataHandler
        • GameData
        • GameDataManager
      • 03.2 Editor
      • 03.3 Item Registry
        • ItemRegistry
        • ItemRegistryEditor
        • ItemRegistryAssetProcessor
      • 03.4 Main Menu
        • SaveSlot
        • SaveSlotsMenu
      • 03.5 Objects Save Data
        • CustomSaveData
      • 03.6 Serialization
        • SerializableVector3
        • SafeSerializationBinder
      • 03.7 Triggers
        • SaveTrigger
        • LoadTrigger
        • ToggleAutoSave
      • 03.8 Type Registry
        • TypeRegistry
        • TypeToPrefabMappingDrawer
      • 03.9 UI
        • SaveLoadButton
    • 04. Shared Content for Add-Ons
      • ToastManager
      • WorkLight
  • HOW TO USE & GUIDES
    • Save & Load Games Programmatically
    • Saving Custom Data: Simple Method
    • Saving Custom Data: Advanced Method
    • Loading Custom Data
    • Saving Instantiated Objects
    • Save & Load System during Development
    • Working with Save & Load in Cowsins Manager
    • Uninstalling the Add-On: Fixing Errors
    • Type to Prefab Mappings in Game Data Manager
    • How to add Buttons to Save & Load a game
    • Non-Saveable Scenes
    • Loading Scenes & Load Player Data
  • FAQ
    • FAQ
  • SUPPORT
    • Support
Powered by GitBook
On this page
  • Saving & Loading the Game programmatically
  • Profile ID Management in Save & Load System
  • CONFIGURATION
  • Functions | DataPersistenceManager.cs
  1. CONTENT
  2. 03. Content
  3. 03.1 DataPersistence

DataPersistenceManager

PreviousDataPersistence_SONextFileDataHandler

Last updated 1 month ago

The DataPersistenceManager interacts with the to manage data encryption and decryption, allowing the to process and load game data seamlessly.

IMPORTANT: The DataPersistenceManager must exist in the scene for data to be saved.

You don’t need to manually add the DataPersistenceManager to each scene, as it is marked with [DontDestroyOnLoad]. Simply place the DataPersistenceManager in your Main Menu scene. When starting the game in a gameplay scene, data won’t be saved. However, when starting from the Main Menu, the DataPersistenceManager will persist across different scenes, ensuring data can be saved.

Saving & Loading the Game programmatically

In Save & Load Pro Add-On, saving the game is very simple! You can access DataPersistenceManager.cs Singleton to Save & Load the game with a single line of code.

Only the Data Stored in GameDataManager will be saved into the Game Data Json, so make sure to Store the Required Data, otherwise nothing will be saved.

In order to access DataPersistenceManager, ensure to add the following library on top of your Script:

using cowsins.SaveLoad; // Required to access DataPersistenceManager

Saving Games Programmatically

DataPersistenceManager.instance.SaveGame();

Loading Games Programmatically

DataPersistenceManager.instance.Loadame();

Profile ID Management in Save & Load System

The DataPersistenceManager manages Profile IDs and interacts with the Save & Load Pro Add-On to handle data operations across different save slots. It maintains a Profile ID to monitor the current save slot, allowing for specific operations based on this ID. The Profile ID remains unchanged during gameplay and can only be modified from the Main Menu when selecting a different save slot.


CONFIGURATION

Functions | DataPersistenceManager.cs

ChangeSelectedProfileId(string newProfileId)

Selects a new Save Slot.

  • newProfileId: New Save Slot Index.

SaveGame()

Saves the Game ( Saves the Stored Data in GameDataManager into a Json file that corresponds to the current Profile ID )

LoadGame()

Loads the Game ( Loads the Data from the Json file that corresponds to the current Profile Id )

HasGameData() | Returns Bool

Returns False if the Game Data is empty or null.

GetLastUsedProfileID() | Returns String

Returns the most recently played Profile ID ( That corresponds to a Save Slot )

IsAutoSaveEnabled() | Returns Bool

Returns true if Auto Save is enabled.

EnableAutoSave()

Enables Auto Save.

DisableAutoSave() |

Disables AutoSave

IsNonSaveableScene() | Returns Bool

Returns true if the current scene should not implement Save & Load Functionality.

GetCurrentGameData() | Returns GameData

Returns Current Game Data

dataPersistenceSettings: Defines General Settings for the Save & Load. These settings can be configured in the Save & Load Tab of the Cowsins Manager. Check for more information.

FileDataHandler
GameDataManager
DataPersistence_SO