示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }