- Home /
Make runtime-instantiated game objects persistent OR make their unique ID persistent
So I am working on a VR Room where I have a room. Currently I have a set of items (game objects) already placed in the room and user can interact with them (change position and material). I have been able to create a UniqueID system (every savable object has a Unique ID script with a public unique Id string that persists between runs. The system is based on this: https://www.gamasutra.com/blogs/SamanthaStahlke/20170621/300187/Building_a_Simple_System_for_Persistence_with_Unity.php ) So currently, I can save user progress through serialization. So I am able to load user's changes on the next run.
But next, I am planning to add a panel to the scene from where the user can add a new item (through prefab) at runtime. This will instantiate the prefab. I am wondering how I can extend the Unique ID system to such game objects instantiated at runtime. If it were only a single instance from one prefab, that could work because the Unique ID of the prefab and the first instantiated game object would be same and it would persist between runs. But since user can create multiple items from a prefab in the scene, I am unable to think of any idea because on each run, the UniqueID script would be attached to the instantiated items at runtime and that would be different each time.
So I either need to find a way of saving the new game objects permanently to the scene (which may not be possible) OR I need to be able to make the UniqueID persistent for those runtime instantiated game objects.
Your answer
![](https://koobas.hobune.stream/wayback/20220613011422im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Prefabs wont instantiate? 2 Answers
Saving players progress in ScriptableObject asset 1 Answer
Get Asset at runtime by its ID 0 Answers
Best way to save and load all objects and their parameters in a scene. 3 Answers
Instanciate prefab responsively 1 Answer