Unity 4: Use SetActive() and not affect children of the gameobject

Hello,

I’m having a bit of a problem switching from Unity 3 to Unity 4 and one of the problems is the removal of the .active and .SetActiveRecursively() and both were merged into a single function, SetActive() which activates the gameobject and all of its children.
There were also added two variables, .activeSelf and .activeInHierarchy, but both are Read Only.

So my question is, is there a simple way to activate only the gameobject and not its children?
I know a way but it’s more complicated than a simple method implemented into the gameobject component… It would be to do a foreach for every children of the object and set those to false but it’s way more complicated and less efficient than a single function.

Thanks.

Unity does not support having children active and parents deactivate any longer. You need to change your setup to accommodate the new system…

Well that’s bad… I’m going to have to change things to be back to normal.
Thanks for the reply :slight_smile:

I just have other question:
How can i enable an object and every children through the inspector?, it’s only enabling the parent and not the children.
This didn’t happen in Unity 3.5.

Actually, it sounds like he’s trying to do the reverse - parent active, children not active. Is that also impossible?

Did you check to make sure that each child is locally active?