Пример #1
0
 public static void DestroyChildren(this Transform transform)
 {
     Transform[] children = transform.GetChildren().ToArray();
     foreach (Transform child in children)
     {
         ObjectEx.SafeDestroyImmediate(child.gameObject);
     }
 }
Пример #2
0
 public static void DestroyChildren <TBehaviour>(this Transform transform) where TBehaviour : MonoBehaviour
 {
     Transform[] children = transform.GetChildren().ToArray();
     foreach (Transform child in children)
     {
         if (child.HasComponent <TBehaviour>())
         {
             ObjectEx.SafeDestroyImmediate(child.gameObject);
         }
     }
 }