From 71c8bc14998763e7fb159ee4459df6c93b11bc57 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 12 Aug 2023 22:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Chart`=E5=9C=A8=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E8=A2=AB=E5=88=A0=E9=99=A4=E6=97=B6=E4=BC=9A?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#269)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Tooltip/TooltipView.cs | 3 +-- Runtime/Internal/BaseChart.cs | 2 ++ Runtime/Internal/BaseGraph.cs | 7 ++++++- Runtime/Internal/Object/ChartLabel.cs | 7 +++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 6cc89409..c352f1fb 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -76,6 +76,7 @@ slug: /changelog 日志详情: +* (2023.08.12) 修复`Chart`在运行时被删除时会异常报错的问题 (#269) * (2023.08.11) 修复`DataZoom`开启时可能会导致无法添加数据的问题 * (2023.08.11) 修复`SerieData`单独设置`ItemStyle`的`itemFormatter`不生效的问题 * (2023.08.10) 优化`BarChart`在`Tooltip`的`Trigger`为`Item`时的表现 diff --git a/Runtime/Component/Tooltip/TooltipView.cs b/Runtime/Component/Tooltip/TooltipView.cs index ba2d84bc..410cb1e9 100644 --- a/Runtime/Component/Tooltip/TooltipView.cs +++ b/Runtime/Component/Tooltip/TooltipView.cs @@ -72,8 +72,7 @@ namespace XCharts.Runtime var ignoreColumn = string.IsNullOrEmpty(tooltip.ignoreDataDefaultContent); var titleActive = !string.IsNullOrEmpty(data.title); - if (titleActive != title.gameObject.activeSelf) - title.gameObject.SetActive(titleActive); + ChartHelper.SetActive(title, titleActive); title.SetText(data.title); m_ColumnMaxWidth.Clear(); diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index c58321d1..de49fb13 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -323,6 +323,8 @@ namespace XCharts.Runtime protected override void OnDestroy() { + base.OnDestroy(); + XChartsMgr.RemoveChart(chartName); for (int i = transform.childCount - 1; i >= 0; i--) { DestroyImmediate(transform.GetChild(i).gameObject); diff --git a/Runtime/Internal/BaseGraph.cs b/Runtime/Internal/BaseGraph.cs index 8e1a8bca..c723a829 100644 --- a/Runtime/Internal/BaseGraph.cs +++ b/Runtime/Internal/BaseGraph.cs @@ -127,16 +127,21 @@ namespace XCharts.Runtime } #if UNITY_EDITOR - protected override void Reset() { } + protected override void Reset() + { + base.Reset(); + } protected override void OnValidate() { + base.OnValidate(); m_IsOnValidate = true; } #endif protected override void OnDestroy() { + base.OnDestroy(); for (int i = transform.childCount - 1; i >= 0; i--) { DestroyImmediate(transform.GetChild(i).gameObject); diff --git a/Runtime/Internal/Object/ChartLabel.cs b/Runtime/Internal/Object/ChartLabel.cs index 33d6e3bd..7464d27e 100644 --- a/Runtime/Internal/Object/ChartLabel.cs +++ b/Runtime/Internal/Object/ChartLabel.cs @@ -55,10 +55,17 @@ namespace XCharts.Runtime protected override void Awake() { + base.Awake(); raycastTarget = false; SetActive(true); } + protected override void OnDestroy() + { + base.OnDestroy(); + GraphicRegistry.UnregisterGraphicForCanvas(canvas, this); + } + public void SetTextPadding(TextPadding padding) { m_PaddingLeft = padding.left;