Remember Component (RememberComposite)

TL;DR – A Remember Component (class RememberComposite) is a tidy wrapper that groups one or more SaveableComponent helpers (Remember Transform, Remember GameObject, etc.) so a whole GameObject can be

1 What the component does

RememberComposite (In the inspector named Remember Component) is a container that lives on a GameObject. Inside that container you add one or more SaveableComponent subclasses – each captures a single aspect of the object:

Helper
Data captured

RememberTransform

Local/world position, rotation & scale (optionally character-controller safe)

RememberRigidbody

Velocity, drag, kinematic flag, gravity, constraints

RememberAnimator

Layer-0 state hash + normalised time

RememberGameObject

Active state, tag, layer, (optional) name & destruction

PersistentVisibilityController

What to disable when the object is off-screen

Your own SaveableComponent

Any custom runtime state you need

During Save every active SaveableComponent on the object serialises itself and registers its payload under a unique key:

<GameObject-UniqueID>_<ComponentID>

2 Requirements

  • Crystal Save Core

  • Crystal Save Settings installed


3 Installation & first-time setup

  1. Select the GameObject you want to persist.

  2. Add Component → Crystal Save → Remember Component (this adds RememberComposite).

  3. Inside the composite click Add Remember Component… and pick the helpers you need (e.g. RememberTransform).

  4. Enter Play-mode, move or deactivate the object, then run:

SaveManager.Instance.Save(1);
SaveManager.Instance.Load(1, restoreLastActiveScene:true);

Everything should pop back exactly as it was.


4 Inspector reference

Composite header

Field
Purpose

Keep Across Scenes

Calls DontDestroyOnLoad on the root GameObject. Only one component per object may enable this.

Visible In Scenes

When Keep Across Scenes is on, list of scenes where the object stays active.

Off-Screen Behaviour

Bit-mask that decides what is disabled when the object is not in its active scene:Colliders, Renderers, CharacterController, RigidbodyKinematic.

Component ID

Read-only GUID; regenerated via Generate New ID if you copied the object.

Remember Home Scene

Helper modules

Each SaveableComponent adds its own mini Inspector (e.g. Transform property check-boxes, CharacterController toggle, etc.). The composite keeps them collapsed by default.

Remember Home Scene Memory

SaveableComponent now shares the same Remember Home Scene workflow as SaveablePrefab, letting you cache component data per scene and replay it when the object returns home.

Designers can choose between:

  • Design Scene – lock the home scene to where the object lives in the editor or first spawned.

  • Last Snapshot Scene – update the home scene each time the system snapshots the object, enabling roaming entities to “move house” during play.

Whenever a snapshot is taken, the component’s serialized bytes are written into a per-scene cache alongside prefab references (for Last Snapshot mode), and the cache is replayed when the same scene loads again. The save manager applies the cached data only when the component is back in its designated home scene to prevent cross-scene bleed-through.

Why enable Remember Home Scene?

  • Scene-aware persistence – state is only restored when the owner returns to its home scene, avoiding unintended state pushes in other levels.

  • Roaming object support – Last Snapshot mode tracks the latest scene and can even respawn missing objects via prefab IDs if they were unloaded in the meantime.

  • Design-time convenience – design scene mode auto-fills the home scene during Awake, so you can mark objects and forget about additional configuration.

Example: Traveling NPC

A quest-giver that wanders from the town to a dungeon can run in Last Snapshot mode. When you leave the dungeon and later return, the cached snapshot re-applies their dialogue, inventory, or quest state only in the dungeon scene, and the prefab logic can respawn them if they were unloaded while you were away.

When to leave it disabled

  • Global or persistent objects – Remember Home Scene is mutually exclusive with Keep Across Scenes, so it’s unsuitable for managers or UI objects that should survive every scene transition.

  • High-volume snapshot costs – the feature snapshots every eligible component in the scene, so very large scenes or frequently saved projects may see additional memory churn and serialization time.

  • One-off scenes – if the object never revisits a scene (e.g., an end-game set piece), you gain little benefit from caching its state per scene.

Example: Persistent HUD Manager

A HUD controller that lives in a DontDestroyOnLoad object already stays alive across scene transitions. Enabling Remember Home Scene would conflict with the mutual-exclusion rule and add unnecessary snapshot overhead for a component that never re-enters its “home” scene.


5 How the save / load cycle works

Saving

graph TD
A[SaveManager.Save] --> B[ComponentManager.CollectComponentData]
B --> C[SaveableComponent.SerializeComponentData()]
C -->|bytes| D[SaveData.ComponentsData]
  • Every helper produces a small byte[] via MemoryPack (or your own serializer).

  • The bytes are stored inside the slot file beside prefab state, screenshots, etc.

Loading

  1. Slot file is deserialised → SaveData.

  2. ComponentManager iterates every key / payload pair.

  3. When the matching helper registers itself it immediately receives its bytes through LoadData().

  4. If the helper is not in the scene yet (e.g. prefab still instantiating) the payload is queued and applied later.

Runtime-safety: Helpers can enable/disable CharacterController, NavMeshAgent, etc. during restoration to avoid physics spikes.


6 Scene persistence & off-screen handling

Keep Across Scenes

Turning this on makes the whole GameObject persistent via PersistentManager.MakePersistent. Use Visible In Scenes to whitelist scenes in which the object should stay activeSelf = true; elsewhere the composite applies the chosen Off-Screen Behaviour flags.


7 Tips, limits & best-practices

  • One composite per object. Add multiple helpers next to it – do not nest composites.

  • Use Generate New IDs after duplicating objects in the editor to avoid GUID collisions.

  • ID hierarchy:

    • Scene objects → UniqueID component (auto-added).

    • Runtime-spawned prefabs → their own internal uniqueID managed by SaveablePrefab – safe to pool or clone.

  • Adding RememberGameObject inside a SaveablePrefab is unnecessary – the prefab already tracks name, tag, layer and active state for its children.

  • Path-based look-ups mean renaming child transforms after shipping a save will break loading – keep names stable or use SaveablePrefabs inside complex hierarchies.


8 Extending the system

Need to capture custom data (e.g. health, inventory, dialogue)? Create your own helper:

public sealed class RememberMyHealth : SaveableComponent {
    protected override byte[] SerializeComponentData() {
        return Serializer.Serialize(GetComponent<Health>().CurrentHP);
    }
    protected override void DeserializeComponentData(byte[] data) {
        int hp = Serializer.Deserialize<int>(data);
        GetComponent<Health>().CurrentHP = hp;
    }
}
  • Register it with the composite via Add Remember Component…

  • Keep payloads compact – Crystal Save memoises identical component bytes per slot, so bloated data wastes disk space.


9 Troubleshooting & FAQ

Symptom
Reason & fix

“Nothing restores on load.”

Ensure the composite is enabled and the object has either a UniqueID component or is a SaveablePrefab instance.

Duplicate GUID warning

You copied an object in the editor – click Generate New ID.

Object vanishes in another scene

Add that scene to Visible In Scenes or disable Keep Across Scenes.

Child renamed breaks load

SaveableComponents match by transform path – keep names stable or convert the child to its own SaveablePrefab.

Need to restore mid-game without loading a slot

Call SaveManager.Instance.RestoreSingleGameObject(target);

Quick API snippet

var hp = SaveManager.Instance.ComponentManager
          .FindByComponentID<RememberMyHealth>("c6fb2d19e1fb4b62828c13b97598e52c");

You’re all set – hook your UI buttons to SaveManager.Instance.Save(slot) / Load(slot) and the Remember Component will do the heavy lifting behind the scenes. Happy saving!

Last updated