Instantiation trouble(components on children are toggled off).
I have a toggle that turns off a panel in my UI. When that panel loads up, it fills it in with child panels and on each of those child panels is instantiated a GameObject with a button. This all works just fine.
It turns off just fine. If I turn it back on from this state, all components are set to active, and all is good.
However, if I reactivate this panel, destroy all of its populated child panels, and then use the same exact code to instantiate new panels and their contents, those child objects*from the same prefabs) come in with all of their components inactive. They themselves are active, but images, scripts, etc. are all toggled off. its the same exact code that instantiates these the first time, the only difference I'm aware of is that this action is preceded by a for loop through which I depopulate this panel by destroying its children, and then repopulate it.
Can anybody give me insight into what I'm doing wrong here?
Also, one related question regarding populating the panel. I had to add code to only allow a single instantiation of an object per instantiated panel, because in the foreach loop, for whatever reasons, it was instantiating too many items per panel...something that makes no sense to me given that every pass through the loop should have only been instantiating one panel and then one child object. What exactly is going on there?
thanks very much for any help!
Your answer
Follow this Question
Related Questions
How can i define a costume function for an object in a prefub that I spawn? 1 Answer
Having trouble instantiating prefabs in my 2D game 1 Answer
Store instantiated object in List 2 Answers
my destroy wall code keeps destroying entire object for good 2 Answers
Copy prefab and swap component BEFORE instantiation 0 Answers