Skip to content

Commit

Permalink
Add transform utility method to destroy all children of transform
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmeshmp committed Nov 27, 2020
1 parent dd5e89b commit 82f1e46
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Assets/Src/Library/Runtime/Extensions/Transform.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using UnityEngine;

namespace CodeBlaze.Library.Extensions
{
public static class Utils
{
/// <summary>
/// Destroy all children of transform
/// </summary>
/// <param name="transform"></param>
/// <returns></returns>
public static Transform Clear(this Transform transform)
{
foreach (Transform child in transform)
{
Object.Destroy(child.gameObject);
}

return transform;
}
}
}
3 changes: 3 additions & 0 deletions Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 82f1e46

Please sign in to comment.