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.

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.


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