From 00996b92d0eff89a31c216f12eaa0f8c77b2b6dd Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 31 Oct 2019 09:46:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96DestroyAllChildren=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/XCharts/Runtime/Utility/ChartHelper.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Assets/XCharts/Runtime/Utility/ChartHelper.cs b/Assets/XCharts/Runtime/Utility/ChartHelper.cs index 8d287ca2..4fb650a5 100644 --- a/Assets/XCharts/Runtime/Utility/ChartHelper.cs +++ b/Assets/XCharts/Runtime/Utility/ChartHelper.cs @@ -77,7 +77,7 @@ namespace XCharts public static void DestroyAllChildren(Transform parent) { - if(parent == null) return; + if (parent == null) return; #if UNITY_EDITOR if (PrefabUtility.IsPartOfAnyPrefab(parent.gameObject)) { @@ -87,8 +87,10 @@ namespace XCharts while (parent.childCount > 0) { var go = parent.GetChild(0); - if (go.childCount > 0) DestroyAllChildren(go); - else GameObject.DestroyImmediate(go.gameObject); + if (go != null) + { + GameObject.DestroyImmediate(go.gameObject); + } } }