plusSpawning Persistent Objects

Objects spawned at runtime need special handling to persist, as traditional Instantiate() from Unity will not persist the instantiation.

GameObject obj = SaveManager.InstantiatePersistent(
    "Prefabs/Coin",  // Path in Resources ( string )
    position, 
    rotation
);
circle-exclamation
GameObject obj = await SaveManager.InstantiatePersistentAsync(
    "YourAddressableKey",
    position,
    rotation
);
circle-exclamation

With Callback

Requirements for Spawned Objects

Prefabs MUST have:

  1. GlobalID component

  2. Saveable component (optional but recommended)

How It Works

  1. Spawn: OmniSave generates a unique ID and registers it

  2. Save: Object data from Saveable saved

  3. Load: OmniSave reinstantiates from prefab path and restores state


Last updated