21 lines
537 B
C#
Raw Normal View History

2025-07-14 21:54:09 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class TransformExtensions
{
/// <summary>
/// Destroys all of the transform's children
/// </summary>
/// <param name="transform">The parent</param>
public static void Clear(this Transform transform)
{
while (transform.childCount > 0)
{
Transform child = transform.transform.GetChild(0);
child.SetParent(null);
Object.Destroy(child.gameObject);
}
}
}