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;