From 82f1e463f93976efac5209b4836564098579efb7 Mon Sep 17 00:00:00 2001 From: Dharmesh Prajapati Date: Fri, 27 Nov 2020 20:41:46 +0530 Subject: [PATCH] Add transform utility method to destroy all children of transform --- .../Library/Runtime/Extensions/Transform.meta | 8 +++++++ .../Runtime/Extensions/Transform/Utils.cs | 22 +++++++++++++++++++ .../Extensions/Transform/Utils.cs.meta | 3 +++ 3 files changed, 33 insertions(+) create mode 100644 Assets/Src/Library/Runtime/Extensions/Transform.meta create mode 100644 Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs create mode 100644 Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs.meta diff --git a/Assets/Src/Library/Runtime/Extensions/Transform.meta b/Assets/Src/Library/Runtime/Extensions/Transform.meta new file mode 100644 index 0000000..fde0456 --- /dev/null +++ b/Assets/Src/Library/Runtime/Extensions/Transform.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: be707065ac7fc4fd5a4aa1deedf1fce1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs b/Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs new file mode 100644 index 0000000..74cb323 --- /dev/null +++ b/Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs @@ -0,0 +1,22 @@ +using UnityEngine; + +namespace CodeBlaze.Library.Extensions +{ + public static class Utils + { + /// + /// Destroy all children of transform + /// + /// + /// + public static Transform Clear(this Transform transform) + { + foreach (Transform child in transform) + { + Object.Destroy(child.gameObject); + } + + return transform; + } + } +} \ No newline at end of file diff --git a/Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs.meta b/Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs.meta new file mode 100644 index 0000000..61de30a --- /dev/null +++ b/Assets/Src/Library/Runtime/Extensions/Transform/Utils.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7a3655dcfaa744d7a2ccd2683cab82bd +timeCreated: 1606487182 \ No newline at end of file