From 29b1f8a8c291da1baa95c59b7b473444e07d4356 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 15 Jan 2025 08:30:50 +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=E5=8A=A8=E6=80=81=E6=B7=BB=E5=8A=A0`Componen?= =?UTF-8?q?t`=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98=20(#339)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Internal/BaseChart.Component.cs | 1 + Runtime/Internal/BaseChart.cs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index d211113e..9a367767 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -79,6 +79,7 @@ slug: /changelog ## master +* (2025.01.15) 修复`Chart`在运行时动态添加`Component`异常的问题 (#339) * (2025.01.08) 修复`TextMeshPro`关闭时残留组件影响`Text`初始化的问题 ## v3.13.0 diff --git a/Runtime/Internal/BaseChart.Component.cs b/Runtime/Internal/BaseChart.Component.cs index 32de3739..c4555cf2 100644 --- a/Runtime/Internal/BaseChart.Component.cs +++ b/Runtime/Internal/BaseChart.Component.cs @@ -52,6 +52,7 @@ namespace XCharts.Runtime public MainComponent AddChartComponent(Type type) { + InitListForFieldInfos(); if (!CanAddChartComponent(type)) { Debug.LogError("XCharts ERROR: CanAddChartComponent:" + type.Name); diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index df21b6f9..a1af1388 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -724,7 +724,7 @@ namespace XCharts.Runtime private void InitListForFieldInfos() { - if (m_TypeListForSerie.Count != 0) return; + if (m_TypeListForSerie.Count != 0 || m_TypeListForComponent.Count != 0) return; m_TypeListForComponent.Clear(); m_TypeListForSerie.Clear(); var fileds1 = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);