mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 07:20:08 +00:00
3.0 - inspector
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffd6706dd3dd048d5ab9c538c133e963
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user