I have recently started working on a script that is supposed to store an array of GameObjects at one scene to be instantiated at another, but the GameObjects don’t persist when changing scenes. Are there any tricks available to change that? the script itself is attached to an empty GameObject with DontDestroyOnLoad enabled.
When you load a new scene, the scene list is cleared and all objects in the current scene are destroyed. If you don’t want this to happen, then you have to explicitly set the DontDestroyOnLoad property to true for each object that you want to preserve for the next scene.
Edit:
I guess I didn’t read your question thoroughly enough. Sounds like you’re already doing this.
mh, i am still a newbie and i am sure there is a better way, but how about something like giving each entry of the array a key
store the key in f.e. the playerprefs then in the new scene if the key exists - recreate the objects (or even the whole array again).
mh, i am still a newbie and i am sure there is a better way, but how about something like giving each entry of the array a key
store the key in f.e. the playerprefs then in the new scene if the key exists - recreate the objects (or even the whole array again).