Hello I am trying to figure out how to find the topmost parent object in the hierarchy of other objects. I have tried using "root" but that only gives me the parent object of the child object I call the script from. I will try to give a better example here.
![alt text][1]
[1]: /storage/temp/44005-project.jpg
What I am trying to figure out is how to get a list of all the object within the Canvas. The script is being called from the button that is highlighted in the screen shot. The problem that I am running into is every time all that I can get is the panel that contains the button. Here is the code I was trying to use.
public void Button1_Click()
{
foreach (Transform t in transform.root)
{
Debug.Log(t.name);
}
}
When I use this code the only thing that is returned is the panel itself. How can I get the code to return the following items:
1. Panel
2. Button
3. Button
4. Button
Thank you for your help in advance.
↧