GameObject parent = GameObject.Find("Parent GameObject"); Listhierarchy = NGUITools.GetHierarchy(parent); foreach(Transform child in hierarchy) { Debug.Log(child.name); }
GameObject[] allObjects = UnityEngine.Object.FindObjectsOfTypeThis code retrieves an array of all GameObjects in the Unity scene. It then loops through each object and retrieves its hierarchy list. Within the hierarchy, it then searches for a specific child transform named "Target Object". If it finds the target object, it logs a message to the console. Overall, NGUITools.GetHierarchy is a useful method in the NGUI package library for Unity3D development when working with gameObject hierarchies.(); foreach(GameObject obj in allObjects) { List hierarchy = NGUITools.GetHierarchy(obj); foreach(Transform child in hierarchy) { if(child.name == "Target Object") { Debug.Log("Found the target object in hierarchy!"); break; } } }