public static IEnumerable <GameObject> GetChildren(this GameObject go) { List <Transform> lst = new List <Transform>(); UnityExtensions.GetChildrenImpl(go.transform, ref lst); return(from child in lst select child.gameObject); }
private static void GetChildrenImpl(Transform parent, ref List <Transform> lst) { if (lst == null) { lst = new List <Transform>(); } if (parent.childCount <= 0) { return; } foreach (Transform child in parent) { lst.Add(child); UnityExtensions.GetChildrenImpl(child, ref lst); } }