Can someone please explain to me what this is/means?
gameObject.SetActiveRecursively(true);
Can someone please explain to me what this is/means?
gameObject.SetActiveRecursively(true);
activate all children of a gameobject
what do you mean activate?
Or deactivate them ![]()
(Also, the function activates/deactivates the game object on which it’s called in addition to that game object’s children.)
How’s this different then destroying then?
Game objects can be active or inactive. I’m not sure how much the docs have to say about this, but active and inactive game objects are treated differently by the engine. (For example, inactive objects don’t receive messages such as Update() and so on, aren’t rendered, and aren’t returned by queries such as FindWithTag() and so on.)
For one thing, inactive objects remain in the scene and can be reactivated later if desired.
So the code and the gameobject is destroyed, only it can be recreated as it was later?
It’s not destroyed and recreated, it’s deactivated and reactivated. (It’s more or less like the difference between turning your TV off and turning it on again later, and throwing your TV away every time you’re done watching it and then buying a new one whenever you want to watch it again.)
The reason why I put it like that was because I was wondering if it kept colliders and visibility. Does it?
It’s the same thing as checking the box next to an object’s name in the inspector. That makes it active or inactive.
–Eric
Hilarious, spot-on analogy.
I found an instance where this is not the case. When I manually activate a ragdoll using the inspector it works as intended but when I use SetActiveRecursively(true) all my joints seem to want to go to the world origin…
More info in here:
http://forum.unity3d.com/threads/77995-Problem-with-SetActiveRecursively-on-a-ragdoll