3.0 - inspector

This commit is contained in:
monitor1394
2022-02-25 08:10:09 +08:00
parent e72349a69f
commit 1ee0df09eb
43 changed files with 217 additions and 1004 deletions

View File

@@ -15,6 +15,9 @@ namespace XCharts.Editor
PropertyField("m_Top");
PropertyField("m_Bottom");
PropertyField("m_BackgroundColor");
PropertyField("m_ShowBorder");
PropertyField("m_BorderWidth");
PropertyField("m_BorderColor");
--EditorGUI.indentLevel;
}
}

View File

@@ -10,19 +10,17 @@ namespace XCharts.Editor
{
protected const string MORE = "More";
protected bool m_MoreFoldout = false;
internal BaseChart chart { get; private set; }
internal MainComponent component { get; private set; }
public BaseChart chart { get; private set; }
public MainComponent component { get; private set; }
//Editor m_Inspector;
internal SerializedProperty baseProperty;
internal SerializedProperty showProperty;
public SerializedProperty baseProperty;
public SerializedProperty showProperty;
internal void Init(BaseChart chart, MainComponent target, SerializedProperty property, UnityEditor.Editor inspector)
{
this.chart = chart;
this.component = target;
this.baseProperty = property;
//m_Inspector = inspector;
showProperty = baseProperty.FindPropertyRelative("m_Show");
if (showProperty == null)
showProperty = baseProperty.FindPropertyRelative("m_Enable");

View File

@@ -32,7 +32,6 @@ namespace XCharts.Editor
this.chart = chart;
m_ComponentsProperty = componentProps;
//m_SerializedObject = serializedObject;
Assert.IsNotNull(m_ComponentsProperty);
@@ -73,24 +72,17 @@ namespace XCharts.Editor
if (chart == null)
return;
// if (chart.isDirty)
// {
// RefreshEditors();
// chart.isDirty = false;
// }
// Override list
for (int i = 0; i < m_Editors.Count; i++)
{
var editor = m_Editors[i];
string title = editor.GetDisplayTitle();
int id = i; // Needed for closure capture below
int id = i;
bool displayContent = ChartEditorHelper.DrawHeader(
title,
editor.baseProperty,
editor.showProperty,
() => { },
() => { ResetComponentEditor(id); },
() => { RemoveComponentEditor(id); }
);
if (displayContent)
@@ -99,11 +91,7 @@ namespace XCharts.Editor
}
}
if (m_Editors.Count > 0)
{
//EditorGUILayout.Space();
}
else
if (m_Editors.Count == 0)
{
EditorGUILayout.HelpBox("No componnet.", MessageType.Info);
}
@@ -151,6 +139,14 @@ namespace XCharts.Editor
AssetDatabase.Refresh();
}
private void ResetComponentEditor(int id)
{
m_Editors[id].component.Reset();
EditorUtility.SetDirty(chart);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
private void RemoveComponentEditor(int id)
{
m_Editors[id].OnDisable();

View File

@@ -1,36 +0,0 @@
using UnityEditor;
using XCharts.Runtime;
namespace XCharts.Editor
{
[ComponentEditor(typeof(Vessel))]
public class VesselEditor : MainComponentEditor<Vessel>
{
public override void OnInspectorGUI()
{
++EditorGUI.indentLevel;
var shape = (Vessel.Shape)baseProperty.FindPropertyRelative("m_Shape").intValue;
PropertyField("m_Shape");
PropertyField("m_ShapeWidth");
PropertyField("m_Gap");
PropertyTwoFiled("m_Center");
PropertyField("m_BackgroundColor");
PropertyField("m_Color");
PropertyField("m_AutoColor");
switch (shape)
{
case Vessel.Shape.Circle:
PropertyField("m_Radius");
PropertyField("m_Smoothness");
break;
case Vessel.Shape.Rect:
PropertyField("m_Width");
PropertyField("m_Height");
PropertyField("m_CornerRadius");
break;
}
--EditorGUI.indentLevel;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ffd6706dd3dd048d5ab9c538c133e963
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: