Elements of Listare null after loading scene
Hi! I have a serious problem with my Singleton. I have "Skills" gameobjects, they have Image, Button and Skill Component. In Skill Component I keep data like id, cooldown, damage etc. It's on my "Start Scene"
When the game starts I simply load skills values from XML - if no XML then I do a little magic and in the parent of all gameobjects with "Skill" Component I do
someparent.GetComponentsInChildren<Skill>()
This way I save all skills to XML.
Loaded skills I keep in singleton in AllSkillsList. It has dontdestroydOnLoad, but when the next scene loads, Elements (Skill type) of the list are null. List still have right amount - but objects in it are null.
What could cause that?
Answer by RudyTheDev · Sep 22, 2015 at 09:09 PM
Presumably, the someparent
wasn't transferred between scenes or its children weren't. Do a GetInstanceID before and after the scene load and see if someparent
and/or its children are actually the same object.
Your answer
Follow this Question
Related Questions
NullReferenceException: Object reference not set to an instance of an object error 0 Answers
if (gameobject != null) giving UnassignedReferenceException 2 Answers
Saving gameObjects state on load 0 Answers
"Method arguments are incompatible" when loading a scene 1 Answer
ArgumentException: The prefab you want to instantiate is null. 2 Answers