2021-01-11 08:54:28 +08:00
|
|
|
|
/************************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 - 2021 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/************************************************/
|
2019-10-22 04:09:04 +08:00
|
|
|
|
|
2019-07-14 14:34:18 +08:00
|
|
|
|
using UnityEditor;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(Axis), true)]
|
2021-01-11 08:54:28 +08:00
|
|
|
|
public class AxisDrawer : BasePropertyDrawer
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
public override string ClassName { get { return "Axis"; } }
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
base.OnGUI(pos, prop, label);
|
|
|
|
|
|
if (MakeFoldout(prop, "m_Show"))
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
|
|
|
|
|
SerializedProperty m_LogBase = prop.FindPropertyRelative("m_LogBase");
|
|
|
|
|
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
|
|
|
|
|
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
2019-05-16 09:39:58 +08:00
|
|
|
|
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
2021-01-11 08:54:28 +08:00
|
|
|
|
var chart = prop.serializedObject.targetObject as BaseChart;
|
|
|
|
|
|
var isPolar = chart is PolarChart;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
EditorGUI.indentLevel++;
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, isPolar ? "m_PolarIndex" : "m_GridIndex");
|
|
|
|
|
|
PropertyField(prop, "m_Type");
|
|
|
|
|
|
PropertyField(prop, "m_Position");
|
|
|
|
|
|
PropertyField(prop, "m_Offset");
|
2020-01-15 19:41:21 +08:00
|
|
|
|
if (type == Axis.AxisType.Log)
|
|
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_LogBaseE");
|
2020-09-24 09:36:09 +08:00
|
|
|
|
EditorGUI.BeginChangeCheck();
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_LogBase");
|
2020-09-24 09:36:09 +08:00
|
|
|
|
if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_LogBase.floatValue = 10;
|
|
|
|
|
|
}
|
|
|
|
|
|
EditorGUI.EndChangeCheck();
|
2020-01-15 19:41:21 +08:00
|
|
|
|
}
|
2019-05-16 09:39:58 +08:00
|
|
|
|
if (type == Axis.AxisType.Value)
|
|
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_MinMaxType");
|
2019-05-16 09:39:58 +08:00
|
|
|
|
Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
|
|
|
|
|
|
switch (minMaxType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Axis.AxisMinMaxType.Default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Axis.AxisMinMaxType.MinMax:
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Axis.AxisMinMaxType.Custom:
|
|
|
|
|
|
EditorGUI.indentLevel++;
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_Min");
|
|
|
|
|
|
PropertyField(prop, "m_Max");
|
2019-05-16 09:39:58 +08:00
|
|
|
|
EditorGUI.indentLevel--;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_CeilRate");
|
|
|
|
|
|
PropertyField(prop, "m_Inverse");
|
2019-05-16 09:39:58 +08:00
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_SplitNumber");
|
2020-09-13 20:17:11 +08:00
|
|
|
|
if (type == Axis.AxisType.Category)
|
|
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_BoundaryGap");
|
2020-09-13 20:17:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
PropertyField(prop, "m_Interval");
|
2020-09-13 20:17:11 +08:00
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
DrawExtendeds(prop);
|
|
|
|
|
|
PropertyField(prop, "m_AxisLine");
|
|
|
|
|
|
PropertyField(prop, "m_AxisName");
|
|
|
|
|
|
PropertyField(prop, "m_AxisTick");
|
|
|
|
|
|
PropertyField(prop, "m_AxisLabel");
|
|
|
|
|
|
PropertyField(prop, "m_SplitLine");
|
|
|
|
|
|
PropertyField(prop, "m_SplitArea");
|
2019-06-21 09:34:33 +08:00
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
if (type == Axis.AxisType.Category)
|
|
|
|
|
|
{
|
2021-01-17 11:44:47 +08:00
|
|
|
|
PropertyListField(prop, "m_Data", true);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
EditorGUI.indentLevel--;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(XAxis), true)]
|
|
|
|
|
|
public class XAxisDrawer : AxisDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ClassName { get { return "XAxis"; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(YAxis), true)]
|
|
|
|
|
|
public class YAxisDrawer : AxisDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ClassName { get { return "YAxis"; } }
|
|
|
|
|
|
}
|
2020-07-01 09:38:00 +08:00
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(AngleAxis), true)]
|
|
|
|
|
|
public class AngleAxisDrawer : AxisDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ClassName { get { return "AngleAxis"; } }
|
|
|
|
|
|
protected override void DrawExtendeds(SerializedProperty prop)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.DrawExtendeds(prop);
|
|
|
|
|
|
PropertyField(prop, "m_StartAngle");
|
|
|
|
|
|
PropertyField(prop, "m_Clockwise");
|
2020-07-01 09:38:00 +08:00
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
2020-07-01 09:38:00 +08:00
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(RadiusAxis), true)]
|
|
|
|
|
|
public class RadiusAxisDrawer : AxisDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
public override string ClassName { get { return "RadiusAxis"; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[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)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
base.OnGUI(pos, prop, label);
|
|
|
|
|
|
if (MakeFoldout(prop, "m_Show"))
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
PropertyField(prop, "m_Formatter");
|
|
|
|
|
|
PropertyField(prop, "m_Inside");
|
|
|
|
|
|
PropertyField(prop, "m_Interval");
|
|
|
|
|
|
PropertyField(prop, "m_Margin");
|
|
|
|
|
|
PropertyField(prop, "m_NumericFormatter");
|
|
|
|
|
|
PropertyField(prop, "m_ShowAsPositiveNumber");
|
|
|
|
|
|
PropertyField(prop, "m_OnZero");
|
|
|
|
|
|
PropertyField(prop, "m_TextLimit");
|
|
|
|
|
|
PropertyField(prop, "m_TextStyle");
|
|
|
|
|
|
--EditorGUI.indentLevel;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
2019-07-14 14:34:18 +08:00
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
2019-06-21 09:34:33 +08:00
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
[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)
|
2020-07-01 09:38:00 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
base.OnGUI(pos, prop, label);
|
|
|
|
|
|
if (MakeFoldout(prop, "m_Show"))
|
|
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
PropertyField(prop, "m_Name");
|
|
|
|
|
|
PropertyField(prop, "m_Location");
|
|
|
|
|
|
PropertyField(prop, "m_TextStyle");
|
|
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
2020-07-01 09:38:00 +08:00
|
|
|
|
}
|
2021-01-11 08:54:28 +08:00
|
|
|
|
}
|
2020-07-01 09:38:00 +08:00
|
|
|
|
|
2021-01-11 08:54:28 +08:00
|
|
|
|
[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)
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
base.OnGUI(pos, prop, label);
|
|
|
|
|
|
if (MakeFoldout(prop, "m_Show"))
|
2019-07-14 14:34:18 +08:00
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
PropertyField(prop, "m_Color");
|
|
|
|
|
|
--EditorGUI.indentLevel;
|
2019-07-14 14:34:18 +08:00
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|