ball testing
This commit is contained in:
36
Assets/Scripts/Utils/Extensions.cs
Normal file
36
Assets/Scripts/Utils/Extensions.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
|
||||
public static class CustomExtensions{
|
||||
public static void PurgeChildren(this Transform parent){
|
||||
foreach(Transform child in parent.GetComponentsInChildren<Transform>()){
|
||||
if(child == parent){continue;}
|
||||
|
||||
SmartDestroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PurgeChildrenEdit(this Transform parent){
|
||||
for (int i = parent.transform.childCount; i > 0; --i)
|
||||
GameObject.DestroyImmediate(parent.GetChild(0).gameObject);
|
||||
}
|
||||
|
||||
public static void SmartDestroy(UnityEngine.Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
GameObject.DestroyImmediate(obj);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
GameObject.Destroy(obj);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Utils/Extensions.cs.meta
Normal file
11
Assets/Scripts/Utils/Extensions.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 677d3c8524a47b1498d6d5d4013fbc43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user