Restore state of individual Object

This guide shows how to restore just one Prefab or GameObject with Crystal Save using the SaveManager API — without reloading your whole scene or touching anything else.


When to use this

  • “Reset puzzle” button for a specific object

  • Re-open a UI panel to its last state

  • Snap the player or an NPC back to a saved pose

  • Debugging: compare a live object against a prior save


What gets restored

For the chosen object Crystal Save reapplies:

  • Active state (SetActive)

  • Transform (position/rotation/scale)

  • Saved Rigidbody & Animator snapshots (if present)

  • All Remember/SaveableComponent data you attached

  • Runtime prefab modifications (name/tag/layer, mesh/material swaps, etc.)

Tip: Scene objects should have a Remember Component with the helpers you need (e.g., Transform). Runtime/spawned objects should use SaveablePrefab on the prefab asset.


Quick start: three common patterns

A) You already have the GameObject (restore from slot)

B) You only know its UniqueID (restore from slot)

C) Re‑apply from the currently loaded SaveData

If you already loaded a save (and have in‑memory SaveData), you can re-apply just one object:

Full API (what’s available)

1) Restore by GameObject

2) Restore by UniqueID or Prefab Asset ID

You can pass either:

  • the instance UniqueID (scene object or prefab instance), or

  • the prefab asset ID (it will instantiate & restore a new instance if needed).


Examples you can copy‑paste

Restore a vendor chest UI from slot 2

Reset only the moving platform to its saved pose

Restore by ID when you don’t hold a reference

Await restoration with retry + custom policy

Restoring destroyed objects (respawn)

If the object was removed (e.g., breakable crate), use the destroyed-object helpers:

Under the hood, Crystal Save looks up the original prefab, instantiates it, applies component data captured at destruction, and re-registers it for future saves.


Quality-of-life helpers (most recent slot)

Need “restore from the latest save”? Use the extensions:


Events & hooks

  • SaveManager.OnSingleGameObjectRestored(GameObject go) Fired after a targeted restore completes. Great for VFX, SFX, or UI updates.

Example:


Troubleshooting & best practices

  • UniqueID is required. Scene objects should have a UniqueID (via Remember Component). Prefabs should use SaveablePrefab (and be instantiated via your usual flow — using SaveablePrefabFactory is recommended for runtime spawns).

  • Object isn’t found by ID? If no live object exists and the ID is a prefab asset ID, the API will try to instantiate it from the saved slot. If it’s an instance ID that no longer exists and no prefab data is present, you’ll see a warning.

  • Destroyed vs. targeted restore. Use targeted restore for objects that still exist; use destroyed-object restore to respawn things you removed.

  • Cloud enabled? The slot read happens through your configured backend (Unity Cloud Save, Supabase, Firebase, MySQL) or the local mirror — no extra work needed on your side.


Minimal checklist

  • The object has Remember/SaveableComponents for the data you need.

  • Scene object has a UniqueID; runtime prefabs have SaveablePrefab.

  • You saved at least once to the slot you’re restoring from.

  • For ID‑based restore, you’re using the correct UniqueID or Prefab Asset ID.

  • If the object was destroyed, use RestoreDestroyedGameObject.


FAQ

Q: Will this block my main thread? A: Slot I/O is performed asynchronously; the actual re‑apply happens on the main thread and is typically a single frame.

Q: Can I restore multiple things at once? A: Yes, just call RestoreSingleGameObject for each object (or use the “most recent slot” extension that accepts a list).

Last updated