- Home /
Parse Scene Hierarchy
Hi everybody.
I'm really sorry to bother all of you with what I think is a very noobie question, but I can't found any answer about it on the internet so ...
I would like to know if there is a way to recursivly parse the Scene Hierarchy in Unity, in order to, for instance, find specifics Games Components.
Something like
for(int i=0;i<Hierarchy.ChildCount; i++)
{
RecursivFunction(Hierarchy.Child(i));
}
Thanks for your attention!
Answer by Kryptos · Apr 05, 2012 at 02:04 PM
To find specific components, you can use:
FindObjectOfType( typeof(YourTypeHere) ); // returns the first object of this type
FindObjectsOfType( typeof(YourTypeHere) ); // returns an array will all objects of this type
See http://unity3d.com/support/documentation/ScriptReference/Object.FindObjectOfType.html and http://unity3d.com/support/documentation/ScriptReference/Object.FindObjectsOfType.html.
GameOject.Find methods can also be of some help.
Thanks for the workaround, I think this should do the tricks for me. I'm just kinda frustrated by the impossibility to directly access the tree scene / hierarchy .
Don't forget to give 'thumb up' when someone answer your question or add significant insight ;)
Your answer
Follow this Question
Related Questions
Some changes in hierarcy gone after i run play mode ? 0 Answers
Reload a scene without closing the inspector and hierarchy 0 Answers
When and why to put object as child of another? 2 Answers
Is there a problem to build the game in the Hierarchy without loading scenes at all ? 0 Answers
Gui 3.4 on MacOSX, no hirearchy, no default scene with demo 1 Answer