- Home /
Keep list of GameObjects between scenes
Hey so i have been building an extremely complex system using lists infact there is like 15 lists all doing there job, here is two problems i have run in to.
If the lists is a bunch of gameobjects for example equipment and i go list.add(equipment) then when a new scene is loaded all gameobjects from the list says missing, but it add'd the prefab object not the clone object i have also add'd the clone object and it also never worked.
After #1 never worked i decided to hold the list's on the same scenes and dontdestroyonload with them and again when the scene loaded in to another one every gameobject was missing from the lists.
So as you can see my problem with carrying over the gameobject is crucial, i could easily call dontdestroyonload on the equipment but then when a new scene loads the equipment will exist in the scene alway's and i don't want that to happen because the equipent will be instantiated from the list when needed.
I am a bit confused as to why the list would not continue to hold the information given to it from before.
Also i tried to add a gameobject to a list that was on another scene to try it that way and it still deletes the object on load.
Answer by erik_wagner · Aug 05, 2015 at 09:06 PM
I'm not sure I understand exactly what you need but I had something that I needed lists for in different scenes. The way I handled it was to create a parent c# class and declare/manipulate the lists there, then have the classes on the relevant scenes' scripts inherit from that class. Hope that helps in some way.
Answer by gamedevelopmenttsunami · Nov 28, 2017 at 02:41 AM
I want to do the same thing but no luck. When the scene changes all the objects stored in the list dissapear.
Your answer
Follow this Question
Related Questions
Return a gameObject from LINQ .GroupBy() 1 Answer
What is the best way to instatiate an array of connected GameObjects? 0 Answers
How do i remove a list item from the scene while adding the next? 1 Answer
Subtracting the position of transform from the position of Game Objects in a list. 1 Answer
List not adding 1 Answer