重构Component相关代码,调整API接口

This commit is contained in:
monitor1394
2023-02-12 21:22:53 +08:00
parent 22b167981b
commit 4964bca341
57 changed files with 349 additions and 185 deletions

View File

@@ -204,15 +204,15 @@ namespace XCharts.Editor
}
serieDataMenus.Clear();
if (serie.GetType().IsDefined(typeof(SerieDataExtraComponentAttribute), false))
if (serie.GetType().IsDefined(typeof(SerieDataComponentAttribute), false))
{
var attribute = serie.GetType().GetAttribute<SerieDataExtraComponentAttribute>();
var attribute = serie.GetType().GetAttribute<SerieDataComponentAttribute>();
foreach (var type in attribute.types)
{
var size = serieData.FindPropertyRelative(SerieData.extraComponentMap[type]).arraySize;
serieDataMenus.Add(new HeaderMenuInfo("Add " + type.Name, () =>
{
serie.GetSerieData(index).GetOrAddComponent(type);
serie.GetSerieData(index).EnsureComponent(type);
EditorUtility.SetDirty(chart);
}, size == 0));
}

View File

@@ -176,15 +176,15 @@ namespace XCharts.Editor
ConvertSerie(editor.serie, type);
}));
}
if (editor.serie.GetType().IsDefined(typeof(SerieExtraComponentAttribute), false))
if (editor.serie.GetType().IsDefined(typeof(SerieComponentAttribute), false))
{
var attribute = editor.serie.GetType().GetAttribute<SerieExtraComponentAttribute>();
var attribute = editor.serie.GetType().GetAttribute<SerieComponentAttribute>();
foreach (var type in attribute.types)
{
var size = editor.FindProperty(Serie.extraComponentMap[type]).arraySize;
editor.menus.Add(new HeaderMenuInfo("Add " + type.Name, () =>
{
editor.serie.AddExtraComponent(type);
editor.serie.EnsureComponent(type);
RefreshEditors();
chart.RefreshAllComponent();
EditorUtility.SetDirty(chart);
@@ -195,7 +195,7 @@ namespace XCharts.Editor
var size = editor.FindProperty(Serie.extraComponentMap[type]).arraySize;
editor.menus.Add(new HeaderMenuInfo("Remove " + type.Name, () =>
{
editor.serie.RemoveExtraComponent(type);
editor.serie.RemoveComponent(type);
RefreshEditors();
chart.RefreshAllComponent();
EditorUtility.SetDirty(chart);