From 2dc3c2f759d012802b7f8c581fdfed80f335ce8b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 31 Oct 2019 09:40:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8B=96=E5=87=BA=E5=88=B6?= =?UTF-8?q?=E4=BD=9C=E9=A2=84=E8=AE=BE=E6=97=B6=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Demo/Runtime/Demo.cs | 2 +- Runtime/Internal/BaseChart.cs | 2 +- Runtime/Utility/ChartHelper.cs | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Demo/Runtime/Demo.cs b/Demo/Runtime/Demo.cs index 57ffdc46..d2777332 100644 --- a/Demo/Runtime/Demo.cs +++ b/Demo/Runtime/Demo.cs @@ -96,7 +96,7 @@ namespace XCharts var btnPanel = transform.Find("chart_list"); m_BtnClone = transform.Find("btn_clone").gameObject; m_BtnClone.SetActive(false); - //ChartHelper.DestroyAllChildren(btnPanel); + ChartHelper.DestroyAllChildren(btnPanel); foreach (var module in m_ChartModule) { var btnName = "btn_" + module.name; diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index 1f5ab2c5..08066464 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -289,7 +289,7 @@ namespace XCharts { var labelObject = ChartHelper.AddObject(s_SerieLabelObjectName, transform, chartAnchorMin, chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight)); - // ChartHelper.DestroyAllChildren(labelObject.transform); + ChartHelper.DestroyAllChildren(labelObject.transform); int count = 0; for (int i = 0; i < m_Series.Count; i++) { diff --git a/Runtime/Utility/ChartHelper.cs b/Runtime/Utility/ChartHelper.cs index f7a30862..8d287ca2 100644 --- a/Runtime/Utility/ChartHelper.cs +++ b/Runtime/Utility/ChartHelper.cs @@ -12,6 +12,9 @@ using System.Text.RegularExpressions; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; +#if UNITY_EDITOR +using UnityEditor; +#endif namespace XCharts { @@ -74,6 +77,13 @@ namespace XCharts public static void DestroyAllChildren(Transform parent) { + if(parent == null) return; +#if UNITY_EDITOR + if (PrefabUtility.IsPartOfAnyPrefab(parent.gameObject)) + { + return; + } +#endif while (parent.childCount > 0) { var go = parent.GetChild(0);