Prefab Setup
To allow instantiated prefabs to be saved and restored using Persistent Instances, you must configure the prefab correctly before using it in your game.
Game Creator 2 normally cannot save objects created during gameplay. Persistent Instances solves this by registering instantiated prefabs so their Remember memories, Local Variables, and existence can be saved and restored.
Prefab Setup
Open the prefab that you want to be persistent.
The parent GameObject of the prefab must contain a Remember component.
This is the object that will control what data is saved and restored.
Add Memory Instance
Inside the Remember component:
Add a Memory Instance memory.
This allows Persistent Instances to register the object when it is instantiated so it can exist after saving and loading.
Local Variables
Any Local Variables placed on the prefab’s parent GameObject will also be saved automatically.
When the object is restored:
The object will be recreated
Its Remember memories will be restored
Its Local Variables will be restored
This allows spawned objects to keep their state across saves.
Instantiating the Prefab
Once the prefab is configured, you can instantiate it using any normal Game Creator workflow, such as:
Instantiate GameObject instruction
Dropping Items
Custom scripts
Persistent Instances automatically registers the object when it appears in the scene.
No new instructions are required.
Re-Parenting Instantiated Objects
If an instantiated prefab has a parent when the game is saved, Persistent Instances will attempt to restore that same parent relationship when the game is loaded.
For the most reliable results, it is recommended that the parent GameObject also has a Remember component. This allows the save system to track the parent object more reliably.
Re-parenting can still work without a Remember component on the parent, but it may be less reliable depending on the situation.
Recommended setup:
The instantiated prefab has:
A Remember component
A Memory Instance
The GameObject it is parented to also has:
A Remember component
This helps ensure the instance is restored and re-parented correctly when loading a save.
Inspecting Registered Instances
To see which prefabs are currently being handled by Persistent Instances, you can inspect the Instance Catalogue.
Navigate to:
Select InstanceCatalogue.asset to view the instances currently registered by Persistent Instances. This is useful for debugging and verifying that your prefabs are being tracked correctly.
If your prefab does not appear in the catalogue, you can:
Run Game Creator → Persistent Instances → Scan for Prefabs
Or open the prefab, ensure it has a Memory Instance, and save the prefab.
Last updated