using System.Collections.Generic; using UnityEngine; public static class ComponentFinderExtensions { /// /// Æ®·£½ºÆû ±âÁØÀ¸·Î ÀڽĵéÀÇ ÄÄÆ÷³ÍÆ®¸¦ À̸§(key)À¸·Î ¸ÅÇÎ /// public static Dictionary FindComponentDictionary(this Transform root, bool includeInactive = true) where T : Component { var dict = new Dictionary(); var components = root.GetComponentsInChildren(includeInactive); foreach (var comp in components) { if (string.IsNullOrEmpty(comp.name)) continue; if (!dict.ContainsKey(comp.name)) dict[comp.name] = comp; } return dict; } /// /// Dictionary¿¡¼­ key·Î ¾ÈÀüÇÏ°Ô °¡Á®¿À±â /// public static T GetOrNull(this Dictionary dict, string name) where T : UnityEngine.Object { dict.TryGetValue(name, out var value); return value; } }