/// <summary> /// Same as GetComponentsInChildren, but will ignore any children with the NetObject. This allows nesting of NetObjects to be respected. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="t"></param> /// <param name="list">Pass null and a reused list will be used. Consume immediately.</param> public static List <T> GetNestedComponentsInChildren <T>(this Transform t, List <T> list) { System.Type type = typeof(T); if (ReferenceEquals(list, null)) { reusable.Clear(); if (!reusable.ContainsKey(type)) { reusable.Add(type, new List <T>()); } list = reusable[type] as List <T>; } if (!tempLists.ContainsKey(type)) { tempLists.Add(type, new List <T>()); } List <T> temp = tempLists[type] as List <T>; temp.Clear(); list.Clear(); t.AddComponentsFromObject(list, temp); t.RecurseAddChildren(list, temp); return(list); }