- Home /
How do i hide and show a group ob gameobjects?
ive made this
public GameObject stars;
stars.active = false;
and all my game objects are grouped into stars, when i click to hide them, just stop the scripts(rotation etc.) but not hide the entire group.
is there another form to send the code to hide the entire content?
Answer by TheCodeMonkey · Aug 12, 2012 at 02:29 AM
You can use GameObject.SetActiveRecursively(false)
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.SetActiveRecursively.html
This sets a gameObject and all its children to activeor inactive.
so :
stars.SetActiveRecurisvely(false);
Should do the trick
EDIT: sorry the wording of your question makes it look like you wanted the above at first however after reading it over again I am thinking you might be wanting broadcast message
http://docs.unity3d.com/Documentation/ScriptReference/GameObject.BroadcastMessage.html
I've reread the question again and i think SetActiveRecurisvely is exactly what he wants ;).
Active is not the same as hiding. If you make an object inactive it wont respond to physics etc anymore. As important as this is, I dont think there is a way to do this in Unity without using culling masks etc which is extremely time consu$$anonymous$$g. It's quite pathetic.
Answer by octaviomejiadiaz · Aug 13, 2012 at 06:29 PM
Hoo.. thanks a lot, i ve used GameObject.SetActiveRecursively and works perfectly.. is there another option to make this change with a fade? well, thats a plus.
thanks a gain
Active is not the same as hiding. If you make an object inactive it wont respond to physics etc anymore. As important as this is, I dont think there is a way to do this in Unity without using culling masks etc which is extremely time consu$$anonymous$$g. It's quite pathetic.
Your answer
Follow this Question
Related Questions
Hide Things behind game objects? 1 Answer
Hide a gameobject 1 Answer
Reloading a Scene throws NullReferenceException on GO with nested Prefabs 0 Answers
Any other method to hide and show gameobjects? 1 Answer
help hiding object? 2 Answers