For the complete documentation index, see llms.txt. This page is also available as Markdown.

Save System

The Save System allows persistent saving and loading of component state across scenes.

Components

ISaveable

  • Interface to make a behaviour's state persistent.

  • Must define a SaveId (string) and state serialization logic.

SaveableMonoBehaviour

  • Base MonoBehaviour implementing ISaveable for convenience.

  • Override save/load methods to store component-specific data.

SaveManager

  • Central controller that manages all ISaveable components in the scene.

  • Assigns unique IDs and coordinates save/load operations.

  • Editor inspector includes:

    • Assign SaveIds to All Saveables – Generates IDs for unassigned components.

    • Clear and Reassign – Resets IDs and clears stored preferences.

SaveManagerUI

  • Optional UI component to expose save/load/reset actions to the player.

SavePrefs

  • Static helper for storing save data in PlayerPrefs.

  • Includes ResetAll() to clear all stored state.

Example Workflow

  1. Add SaveManager to your scene.

  2. Implement ISaveable on components whose state should persist.

    1. Tip: inherit from SaveableMonoBehaviour for clean integration with Unity callbacks.

  3. Auto-assign unique SaveIds to each object using the SaveManager Inspector component.

  4. Call SavePrefs methods or use SaveManager to save/load.

  5. Add an optional button to your in-app UI to call SaveManager.ResetAllSaveables().

Example Code

Last updated