using System.Collections.Generic; using UnityEngine; namespace TyphoonUI { internal static class GameObjectExtension { public static List GetComponentsInChildrenIncludeInactive(this GameObject gameObject) { List components = new List(); GetComponentsInChildrenIncludeInactiveRecursive(gameObject.transform, components); return components; } private static void GetComponentsInChildrenIncludeInactiveRecursive(Transform transform, List components) { T component = transform.GetComponent(); if (component != null) { components.Add(component); } for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); GetComponentsInChildrenIncludeInactiveRecursive(child, components); } } } }