mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 01:40:06 +00:00
3.0 - inspector
This commit is contained in:
@@ -17,7 +17,6 @@ namespace XCharts.Editor
|
||||
protected SerializedProperty m_Settings;
|
||||
protected SerializedProperty m_Theme;
|
||||
protected SerializedProperty m_ChartName;
|
||||
protected SerializedProperty m_DebugMode;
|
||||
protected SerializedProperty m_DebugInfo;
|
||||
protected SerializedProperty m_RaycastTarget;
|
||||
|
||||
@@ -25,6 +24,7 @@ namespace XCharts.Editor
|
||||
protected List<SerializedProperty> m_Series = new List<SerializedProperty>();
|
||||
|
||||
private bool m_BaseFoldout;
|
||||
|
||||
private bool m_CheckWarning = false;
|
||||
private int m_LastComponentCount = 0;
|
||||
private int m_LastSerieCount = 0;
|
||||
@@ -41,7 +41,6 @@ namespace XCharts.Editor
|
||||
m_ChartName = serializedObject.FindProperty("m_ChartName");
|
||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||
m_Settings = serializedObject.FindProperty("m_Settings");
|
||||
m_DebugMode = serializedObject.FindProperty("m_DebugMode");
|
||||
m_DebugInfo = serializedObject.FindProperty("m_DebugInfo");
|
||||
m_RaycastTarget = serializedObject.FindProperty("m_RaycastTarget");
|
||||
|
||||
@@ -57,7 +56,7 @@ namespace XCharts.Editor
|
||||
public List<SerializedProperty> RefreshComponent()
|
||||
{
|
||||
m_Components.Clear();
|
||||
serializedObject.Update();
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
foreach (var kv in m_Chart.typeListForComponent)
|
||||
{
|
||||
InitComponent(kv.Value.Name);
|
||||
@@ -68,7 +67,7 @@ namespace XCharts.Editor
|
||||
public List<SerializedProperty> RefreshSeries()
|
||||
{
|
||||
m_Series.Clear();
|
||||
serializedObject.Update();
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
foreach (var kv in m_Chart.typeListForSerie)
|
||||
{
|
||||
InitSerie(kv.Value.Name);
|
||||
@@ -83,7 +82,7 @@ namespace XCharts.Editor
|
||||
base.OnInspectorGUI();
|
||||
return;
|
||||
}
|
||||
serializedObject.Update();
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
if (m_LastComponentCount != m_Chart.components.Count)
|
||||
{
|
||||
m_LastComponentCount = m_Chart.components.Count;
|
||||
@@ -107,16 +106,7 @@ namespace XCharts.Editor
|
||||
|
||||
protected virtual void OnStartInspectorGUI()
|
||||
{
|
||||
var version = string.Format("v{0}_{1}", XChartsMgr.version, XChartsMgr.versionDate);
|
||||
if (m_EnableTextMeshPro.boolValue)
|
||||
{
|
||||
version += " TMP";
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField(version);
|
||||
EditorGUILayout.Space();
|
||||
serializedObject.Update();
|
||||
|
||||
ShowVersion();
|
||||
m_BaseFoldout = ChartEditorHelper.DrawHeader("Base", m_BaseFoldout, false, null, null);
|
||||
if (m_BaseFoldout)
|
||||
{
|
||||
@@ -134,13 +124,10 @@ namespace XCharts.Editor
|
||||
|
||||
protected virtual void OnDebugInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_DebugInfo, true);
|
||||
AddSerie();
|
||||
AddComponent();
|
||||
CheckWarning();
|
||||
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
EditorGUILayout.PropertyField(m_DebugMode);
|
||||
EditorGUILayout.PropertyField(m_DebugInfo, true);
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
protected void PropertyComponnetList(SerializedProperty prop)
|
||||
@@ -176,6 +163,15 @@ namespace XCharts.Editor
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowVersion()
|
||||
{
|
||||
sb.Length = 0;
|
||||
sb.AppendFormat("v{0}", XChartsMgr.fullVersion);
|
||||
//if(m_EnableTextMeshPro.boolValue)
|
||||
sb.Append("-tmp");
|
||||
EditorGUILayout.HelpBox(sb.ToString(), MessageType.None);
|
||||
}
|
||||
|
||||
private void AddComponent()
|
||||
{
|
||||
if (GUILayout.Button("Add Component"))
|
||||
@@ -267,9 +263,9 @@ namespace XCharts.Editor
|
||||
if (GUILayout.Button("Covert XY Axis"))
|
||||
m_Chart.CovertXYAxis(0);
|
||||
}
|
||||
if (GUILayout.Button("Remove All Chart Object"))
|
||||
if (GUILayout.Button("Reinit Component"))
|
||||
{
|
||||
m_Chart.RemoveChartObject();
|
||||
m_Chart.ReinitAllChartComponent();
|
||||
}
|
||||
if (m_CheckWarning)
|
||||
{
|
||||
@@ -305,6 +301,7 @@ namespace XCharts.Editor
|
||||
m_CheckWarning = true;
|
||||
m_Chart.CheckWarning();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
26
Editor/ChildComponents/DebugInfoDrawer.cs
Normal file
26
Editor/ChildComponents/DebugInfoDrawer.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(DebugInfo), true)]
|
||||
public class DebugInfoDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Debug"; } }
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
base.OnGUI(pos, prop, label);
|
||||
if (MakeComponentFoldout(prop, ""))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_FoldSeries");
|
||||
PropertyField(prop, "m_ShowDebugInfo");
|
||||
PropertyField(prop, "m_ShowAllChildObject");
|
||||
PropertyField(prop, "m_DebugInfoTextStyle");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ffd6706dd3dd048d5ab9c538c133e963
|
||||
guid: 99bd61acea264400fb4747b17a2731e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -12,7 +12,7 @@ namespace XCharts.Editor
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
base.OnGUI(pos, prop, label);
|
||||
if (MakeComponentFoldout(prop, "", new HeaderMenuInfo("Reset", () =>
|
||||
if (MakeComponentFoldout(prop, "m_Show", new HeaderMenuInfo("Reset", () =>
|
||||
{
|
||||
var chart = prop.serializedObject.targetObject as BaseChart;
|
||||
chart.settings.Reset();
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace XCharts.Editor
|
||||
var defaultWidth = pos.width;
|
||||
var defaultX = pos.x;
|
||||
var chart = prop.serializedObject.targetObject as BaseChart;
|
||||
if (MakeComponentFoldout(prop, "", new HeaderMenuInfo("Reset|Reset to theme default color", () =>
|
||||
if (MakeComponentFoldout(prop, "m_Show", new HeaderMenuInfo("Reset|Reset to theme default color", () =>
|
||||
{
|
||||
chart.theme.sharedTheme.ResetTheme();
|
||||
chart.RefreshAllComponent();
|
||||
|
||||
@@ -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,22 +0,0 @@
|
||||
using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Editor
|
||||
{
|
||||
[SerieEditor(typeof(Liquid))]
|
||||
public class LiquidEditor : SerieEditor<Liquid>
|
||||
{
|
||||
public override void OnCustomInspectorGUI()
|
||||
{
|
||||
PropertyField("m_VesselIndex");
|
||||
PropertyField("m_Min");
|
||||
PropertyField("m_Max");
|
||||
PropertyField("m_WaveLength");
|
||||
PropertyField("m_WaveHeight");
|
||||
PropertyField("m_WaveSpeed");
|
||||
PropertyField("m_WaveOffset");
|
||||
|
||||
PropertyField("m_ItemStyle");
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d62c400d54e9f412abb6a9befbfa3937
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -20,6 +20,7 @@ namespace XCharts.Editor
|
||||
|
||||
Dictionary<Type, Type> m_EditorTypes;
|
||||
List<SerieBaseEditor> m_Editors;
|
||||
private bool m_SerieFoldout;
|
||||
|
||||
|
||||
public SerieListEditor(BaseChartEditor editor)
|
||||
@@ -73,7 +74,22 @@ namespace XCharts.Editor
|
||||
{
|
||||
if (chart == null)
|
||||
return;
|
||||
if (chart.debug.foldSeries)
|
||||
{
|
||||
m_SerieFoldout = ChartEditorHelper.DrawHeader("Series", m_SerieFoldout, false, null, null);
|
||||
if (m_SerieFoldout)
|
||||
{
|
||||
DrawSeries();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSeries();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSeries()
|
||||
{
|
||||
for (int i = 0; i < m_Editors.Count; i++)
|
||||
{
|
||||
var editor = m_Editors[i];
|
||||
@@ -96,6 +112,7 @@ namespace XCharts.Editor
|
||||
|
||||
void RefreshEditors()
|
||||
{
|
||||
m_SerializedObject.UpdateIfRequiredOrScript();
|
||||
foreach (var editor in m_Editors)
|
||||
editor.OnDisable();
|
||||
|
||||
|
||||
@@ -127,13 +127,6 @@ namespace XCharts.Editor
|
||||
AddChart<RingChart>("RingChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/LiquidChart", priority = 53)]
|
||||
[MenuItem("GameObject/XCharts/LiquidChart", priority = 53)]
|
||||
public static void AddLiquidChart()
|
||||
{
|
||||
AddChart<LiquidChart>("LiquidChart");
|
||||
}
|
||||
|
||||
[MenuItem("XCharts/CandlestickChart", priority = 54)]
|
||||
[MenuItem("GameObject/XCharts/CandlestickChart", priority = 54)]
|
||||
public static void CandlestickChart()
|
||||
|
||||
Reference in New Issue
Block a user