Files
XCharts/Editor/MainComponents/AxisEditor.cs

205 lines
7.1 KiB
C#
Raw Normal View History

2021-11-23 13:20:07 +08:00
using UnityEditor;
using UnityEngine;
2022-02-19 22:37:57 +08:00
using XCharts.Runtime;
2021-11-23 13:20:07 +08:00
2021-12-24 13:33:09 +08:00
namespace XCharts.Editor
2021-11-23 13:20:07 +08:00
{
[ComponentEditor(typeof(Axis))]
public class AxisEditor : MainComponentEditor<Axis>
{
public override void OnInspectorGUI()
{
var m_Type = baseProperty.FindPropertyRelative("m_Type");
var m_LogBase = baseProperty.FindPropertyRelative("m_LogBase");
var m_MinMaxType = baseProperty.FindPropertyRelative("m_MinMaxType");
2022-05-22 22:17:38 +08:00
var type = (Axis.AxisType) m_Type.enumValueIndex;
2021-11-23 13:20:07 +08:00
EditorGUI.indentLevel++;
if (component is ParallelAxis)
{
PropertyField("m_ParallelIndex");
}
else if (!(component is SingleAxis))
{
PropertyField("m_GridIndex");
PropertyField("m_PolarIndex");
}
PropertyField("m_Type");
PropertyField("m_Position");
PropertyField("m_Offset");
if (type == Axis.AxisType.Log)
{
PropertyField("m_LogBaseE");
EditorGUI.BeginChangeCheck();
PropertyField("m_LogBase");
if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
{
m_LogBase.floatValue = 10;
}
EditorGUI.EndChangeCheck();
}
if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
{
PropertyField("m_MinMaxType");
2022-05-22 22:17:38 +08:00
Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType) m_MinMaxType.enumValueIndex;
2021-11-23 13:20:07 +08:00
switch (minMaxType)
{
case Axis.AxisMinMaxType.Default:
break;
case Axis.AxisMinMaxType.MinMax:
break;
case Axis.AxisMinMaxType.Custom:
EditorGUI.indentLevel++;
PropertyField("m_Min");
PropertyField("m_Max");
EditorGUI.indentLevel--;
break;
}
PropertyField("m_CeilRate");
if (type == Axis.AxisType.Value)
{
PropertyField("m_Inverse");
}
}
PropertyField("m_SplitNumber");
if (type == Axis.AxisType.Category)
{
//PropertyField("m_InsertDataToHead");
PropertyField("m_MaxCache");
PropertyField("m_BoundaryGap");
}
else
{
PropertyField("m_Interval");
PropertyField("m_BoundaryGap");
}
DrawExtendeds();
PropertyField("m_AxisLine");
PropertyField("m_AxisName");
PropertyField("m_AxisTick");
PropertyField("m_AxisLabel");
PropertyField("m_SplitLine");
PropertyField("m_SplitArea");
PropertyListField("m_Icons", true);
if (type == Axis.AxisType.Category)
{
PropertyListField("m_Data", true, new HeaderMenuInfo("Import ECharts Axis Data", () =>
{
PraseExternalDataEditor.UpdateData(chart, null, component as Axis);
PraseExternalDataEditor.ShowWindow();
}));
}
EditorGUI.indentLevel--;
}
}
[ComponentEditor(typeof(XAxis))]
public class XAxisEditor : AxisEditor
2022-05-22 22:17:38 +08:00
{ }
2021-11-23 13:20:07 +08:00
[ComponentEditor(typeof(YAxis))]
public class YAxisEditor : AxisEditor
2022-05-22 22:17:38 +08:00
{ }
2021-11-23 13:20:07 +08:00
[ComponentEditor(typeof(SingleAxis))]
public class SingleAxisEditor : AxisEditor
{
protected override void DrawExtendeds()
{
base.DrawExtendeds();
PropertyField("m_Orient");
PropertyField("m_Left");
PropertyField("m_Right");
PropertyField("m_Top");
PropertyField("m_Bottom");
PropertyField("m_Width");
PropertyField("m_Height");
}
}
[ComponentEditor(typeof(AngleAxis))]
public class AngleAxisEditor : AxisEditor
{
protected override void DrawExtendeds()
{
base.DrawExtendeds();
PropertyField("m_StartAngle");
PropertyField("m_Clockwise");
}
}
[ComponentEditor(typeof(RadiusAxis))]
public class RadiusAxisEditor : AxisEditor
2022-05-22 22:17:38 +08:00
{ }
2021-11-23 13:20:07 +08:00
[ComponentEditor(typeof(ParallelAxis))]
public class ParallelAxisEditor : AxisEditor
2022-05-22 22:17:38 +08:00
{ }
2021-11-23 13:20:07 +08:00
[CustomPropertyDrawer(typeof(AxisLabel), true)]
public class AxisLabelDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "AxisLabel"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
2022-03-09 07:26:15 +08:00
if (MakeComponentFoldout(prop, "m_Show", true))
2021-11-23 13:20:07 +08:00
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Inside");
PropertyField(prop, "m_Interval");
2022-04-26 08:24:45 +08:00
2021-11-23 13:20:07 +08:00
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_OnZero");
PropertyField(prop, "m_ShowStartLabel");
PropertyField(prop, "m_ShowEndLabel");
2022-04-26 08:24:45 +08:00
PropertyField(prop, "m_Rotate");
2022-05-22 22:17:38 +08:00
PropertyField(prop, "m_Offset");
2022-04-26 08:24:45 +08:00
PropertyField(prop, "m_Distance");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_NumericFormatter");
PropertyField(prop, "m_Width");
PropertyField(prop, "m_Height");
PropertyField(prop, "m_Icon");
PropertyField(prop, "m_Background");
2021-11-23 13:20:07 +08:00
PropertyField(prop, "m_TextStyle");
2022-04-26 08:26:37 +08:00
PropertyField(prop, "m_TextPadding");
2022-05-22 22:17:38 +08:00
PropertyField(prop, "m_TextLimit");
2021-11-23 13:20:07 +08:00
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(AxisName), true)]
public class AxisNameDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "AxisName"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
2022-03-09 07:26:15 +08:00
if (MakeComponentFoldout(prop, "m_Show", true))
2021-11-23 13:20:07 +08:00
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Name");
2022-04-26 08:24:45 +08:00
PropertyField(prop, "m_LabelStyle");
2021-11-23 13:20:07 +08:00
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(AxisSplitArea), true)]
public class AxisSplitAreaDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "SplitArea"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
2022-03-09 07:26:15 +08:00
if (MakeComponentFoldout(prop, "m_Show", true))
2021-11-23 13:20:07 +08:00
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Color");
--EditorGUI.indentLevel;
}
}
}
}