- Home /
Question by
benhumphreys · Sep 02, 2013 at 10:03 AM ·
hierarchy
Race Conditions calling SetActive on a hierarchy
I'm restoring state between menu screens with code like the following:
parent.SetActive(true);
GameObject button = parent.FindRecursive(defaultButttonName);
CameraHelper.SetSelected(button);
The problem is that button
is not active. It seems it takes time for children to be activated when SetActive
is called.
How do people avoid these kinds of race conditions?
Comment
I highly doubt there can be any race conditions with setting objects active/inactive. It runs in the same thread and I've never encountered any problems like that.
There may be a problem with activation if you make object inactive from code or from editor interface(unchecking the box near gameobject's name). Try to leave object active in scene, then make in inactive from code. Or vice-versa, I don't remember exactly which way it was.
Your answer
