- Home /
SetActiveRecursively not activating children
Hello,
I have a scenario where I spawn several objects that initially are turned off via SetActiveRecursively( false ). These objects are compositions of one parent and one to four children. Each child contains a mesh and each parent is attached to a global level object. ie the hierarchy looks like this:
levelObject container 1, 1 child 1 mesh child 2 mesh container 2, 1 child 1 mesh
When the player hits a certain trigger, these inactive objects are activated via a method which calls SetActiveRecursively( true ). At this point the container objects are indeed activated, however the children of these container objects are not.
The strange thing is that when stepping through the code in the debugger, the children's active property is set to true. In the unity editor however, the active checkbox of the child objects is still set to false.
I've tried manually iterating over the children and calling SetActiveRecursively( true ) but that didn't have any effect.
Does anyone have an idea what may prevent the children from activating ?
Cheers
Answer by mlassche · Sep 01, 2011 at 09:12 AM
As it turns out, I was being slightly dense. Putting setActiveRecursively in the start function is not a good idea ... oh well problem solved.
Answer by chaneya · Dec 18, 2011 at 11:58 PM
But why is it bad to use SecActiveRecursively in StartUUp?
I'd assume it can get fired before the childs are even loaded