修复动态添加组件时Inspector可能异常的问题

This commit is contained in:
monitor1394
2023-04-11 08:00:06 +08:00
parent 76238d7d7e
commit f00eb2147d
2 changed files with 6 additions and 2 deletions

View File

@@ -66,6 +66,8 @@ slug: /changelog
## master
* (2023.04.11) 修复动态添加组件时`Inspector`可能异常的问题
## v3.6.0
版本要点:

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;
using XCharts.Runtime;
@@ -102,7 +103,8 @@ namespace XCharts.Editor
editor.OnDisable();
m_Editors.Clear();
for (int i = 0; i < chart.components.Count; i++)
var count = Mathf.Min(chart.components.Count, m_ComponentsProperty.Count);
for (int i = 0; i < count; i++)
{
if (chart.components[i] != null)
{
@@ -119,7 +121,7 @@ namespace XCharts.Editor
if (!m_EditorTypes.TryGetValue(settingsType, out editorType))
editorType = typeof(MainComponentBaseEditor);
var editor = (MainComponentBaseEditor) Activator.CreateInstance(editorType);
var editor = (MainComponentBaseEditor)Activator.CreateInstance(editorType);
editor.Init(chart, component, property, m_BaseEditor);
if (index < 0)