Skip to content

Instantly share code, notes, and snippets.

@andydbc
Created November 8, 2024 15:37
Show Gist options
  • Save andydbc/f4e704e2cc51e286ea39d5f88e721d28 to your computer and use it in GitHub Desktop.
Save andydbc/f4e704e2cc51e286ea39d5f88e721d28 to your computer and use it in GitHub Desktop.
Helper extensions for Transform: delete all child objects of a Transform
using UnityEngine;
public static class TransformExtensions
{
public static void DestroyChildren(this Transform t)
{
foreach (Transform child in t)
{
GameObject.Destroy(child.gameObject);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment