# Extending the save system

!!! note "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.

<div class="grid cards" markdown>

- **[Memory](memories.md)** — capture one aspect of a game object's state.
- **[ISaveLoad](isaveload.md)** — make a component or asset participate directly.
- **[Serializer](serializers.md)** — convert a snapshot to text and back.
- **[Encryption](encryption.md)** — transform serialized text before storage.
- **[Storage](storage.md)** — choose where the serialized data is written.

</div>

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](../../../manual/save-load/settings.md).

## 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](memories.md) | A designer opts in through **Remember**. |
| Save your own component or `ScriptableObject` | [`ISaveLoad`](isaveload.md) | The type controls its identity, scope, and priority. |
| Use a cloud service or custom directory | [Storage](storage.md) | The backend owns reading, writing, existence, and deletion. |
| Use binary or an external schema | [Serializer](serializers.md) | The serializer controls the snapshot format. |
| Obscure stored data | [Encryption](encryption.md) | 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

1. The manager calls `OnSave()` on every subscriber whose scope matches.
2. The manager collects the returned objects in the snapshot.
3. The serializer, encryption, and storage implementations convert and write the snapshot.

### Loading

1. The storage, encryption, and serializer implementations read and reconstruct the snapshot.
2. The manager calls `OnLoad(object)` on persistent subscribers in priority order.
3. The manager loads the recorded scenes.
4. 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](memories.md)** — capture state from components you do not own.
- **[ISaveLoad](isaveload.md)** — save components and assets you own.
- **[Save & Load](../../../manual/save-load/index.md)** — understand the designer-facing lifecycle.
