Extending the save system#
Summary
The save system separates captured state from serialization, encryption, and storage. Extend the layer that owns the required behavior so scene objects, save formats, and backends remain independent.
- Memory — capture one aspect of a game object's state.
- ISaveLoad — make a component or asset participate directly.
- Serializer — convert a snapshot to text and back.
- Encryption — transform serialized text before storage.
- Storage — choose where the serialized data is written.
Start with Memory or ISaveLoad when you need to capture more state. Storage, serialization, and encryption control how that state is written; choose them once per project in Save settings.
Choose by ownership#
The extension point depends on which part of saving your code controls:
| Need | Extend | Reason |
|---|---|---|
| Capture a component you do not own | Memory | A designer opts in through Remember. |
Save your own component or ScriptableObject |
ISaveLoad |
The type controls its identity, scope, and priority. |
| Use a cloud service or custom directory | Storage | The backend owns reading, writing, existence, and deletion. |
| Use binary or an external schema | Serializer | The serializer controls the snapshot format. |
| Obscure stored data | Encryption | Encryption transforms text after serialization. |
The save cycle#
The save system captures state before passing it through serialization, encryption, and storage. Loading reverses that sequence before restoring objects.
Saving#
- The manager calls
OnSave()on every subscriber whose scope matches. - The manager collects the returned objects in the snapshot.
- The serializer, encryption, and storage implementations convert and write the snapshot.
Loading#
- The storage, encryption, and serializer implementations read and reconstruct the snapshot.
- The manager calls
OnLoad(object)on persistent subscribers in priority order. - The manager loads the recorded scenes.
- Scene-bound subscribers restore as their objects initialize.
Persistent subscribers — Global Variables, managers — are restored before the scene, so scene objects can rely on global state already being correct.
Priority#
ISaveLoad.Priority sets the restoration order, with higher values first. Use it when one system needs another system's restored state before its own OnLoad runs.
Keep the default when there's no dependency. If you change the priority, document which system needs to restore first so later changes preserve that order.
Where to go next#
- Memories — capture state from components you do not own.
- ISaveLoad — save components and assets you own.
- Save & Load — understand the designer-facing lifecycle.