//--------------------------------------------------------------------------- #endregion //--------------------------------------------------------------------------- #region Private Member Functions //--------------------------------------------------------------------------- private void CullUselessChildren(GameObject parent) { foreach (Transform child in parent.transform) { List <OCAction> actions = child.gameObject.GetComponentsInChildren <OCAction>(true).ToList(); //actions.AddRange(child.gameObject.GetComponents<OCAction>().ToList()); if (actions == null || actions.Count == 0) { GameObject.Destroy(child.gameObject); } else { if (child.gameObject.GetComponent <OCAction>() == null) { CullUselessChildren(child.gameObject); } } } }