修复Chart在运行时动态添加Component异常的问题 (#339)

This commit is contained in:
monitor1394
2025-01-15 08:30:50 +08:00
parent ddbfd9b7ef
commit 29b1f8a8c2
3 changed files with 3 additions and 1 deletions

View File

@@ -79,6 +79,7 @@ slug: /changelog
## master
* (2025.01.15) 修复`Chart`在运行时动态添加`Component`异常的问题 (#339)
* (2025.01.08) 修复`TextMeshPro`关闭时残留组件影响`Text`初始化的问题
## v3.13.0

View File

@@ -52,6 +52,7 @@ namespace XCharts.Runtime
public MainComponent AddChartComponent(Type type)
{
InitListForFieldInfos();
if (!CanAddChartComponent(type))
{
Debug.LogError("XCharts ERROR: CanAddChartComponent:" + type.Name);

View File

@@ -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);