mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-26 10:50:08 +00:00
优化DestroyAllChildren接口
This commit is contained in:
@@ -77,7 +77,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public static void DestroyAllChildren(Transform parent)
|
public static void DestroyAllChildren(Transform parent)
|
||||||
{
|
{
|
||||||
if(parent == null) return;
|
if (parent == null) return;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
if (PrefabUtility.IsPartOfAnyPrefab(parent.gameObject))
|
if (PrefabUtility.IsPartOfAnyPrefab(parent.gameObject))
|
||||||
{
|
{
|
||||||
@@ -87,8 +87,10 @@ namespace XCharts
|
|||||||
while (parent.childCount > 0)
|
while (parent.childCount > 0)
|
||||||
{
|
{
|
||||||
var go = parent.GetChild(0);
|
var go = parent.GetChild(0);
|
||||||
if (go.childCount > 0) DestroyAllChildren(go);
|
if (go != null)
|
||||||
else GameObject.DestroyImmediate(go.gameObject);
|
{
|
||||||
|
GameObject.DestroyImmediate(go.gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user