Files
XCharts/Editor/MainComponents/MarkAreaEditor.cs

55 lines
1.9 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(MarkArea))]
public class MarkAreaEditor : MainComponentEditor<MarkArea>
{
public override void OnInspectorGUI()
{
++EditorGUI.indentLevel;
PropertyField("m_SerieIndex");
PropertyField("m_Text");
PropertyField("m_ItemStyle");
PropertyField("m_Label");
PropertyField("m_Start");
PropertyField("m_End");
--EditorGUI.indentLevel;
}
}
[CustomPropertyDrawer(typeof(MarkAreaData), true)]
public class MarkAreaDataDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "MarkAreaData"; } }
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, "", true))
2021-11-23 13:20:07 +08:00
{
++EditorGUI.indentLevel;
2022-05-22 22:17:38 +08:00
var type = (MarkAreaType) (prop.FindPropertyRelative("m_Type")).enumValueIndex;
2021-11-23 13:20:07 +08:00
PropertyField(prop, "m_Type");
PropertyField(prop, "m_Name");
switch (type)
{
case MarkAreaType.None:
PropertyField(prop, "m_XPosition");
PropertyField(prop, "m_YPosition");
PropertyField(prop, "m_XValue");
PropertyField(prop, "m_YValue");
break;
case MarkAreaType.Min:
case MarkAreaType.Max:
case MarkAreaType.Average:
case MarkAreaType.Median:
PropertyField(prop, "m_Dimension");
break;
}
--EditorGUI.indentLevel;
}
}
}
}