public void SetEffectComponentToAllChildGraphics(Transform target) { List <UnityEngine.UI.Graphic> graphics = ListPool <UnityEngine.UI.Graphic> .Get(); try { GetComponentsInChildren(true, graphics); for (int i = 0, count = graphics.Count; i < count; ++i) { UnityEngine.UI.Graphic g = graphics[i]; if (g.GetComponent <EffectComponent>() == null) { EffectComponent effect; #if !UNITY_EDITOR effect = g.gameObject.AddComponent <EffectComponent>(); #else effect = Undo.AddComponent <EffectComponent>(g.gameObject); #endif effect.SetParent(this); effect.SetDirty(false); } } } finally { ListPool <UnityEngine.UI.Graphic> .Release(graphics); } }