MarkLineEditor.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Editor
  5. {
  6. [ComponentEditor(typeof(MarkLine))]
  7. public class MarkLineEditor : MainComponentEditor<MarkLine>
  8. {
  9. public override void OnInspectorGUI()
  10. {
  11. ++EditorGUI.indentLevel;
  12. PropertyField("m_SerieIndex");
  13. PropertyField("m_Animation");
  14. PropertyListField("m_Data", true);
  15. --EditorGUI.indentLevel;
  16. }
  17. }
  18. [CustomPropertyDrawer(typeof(MarkLineData), true)]
  19. public class MarkLineDataDrawer : BasePropertyDrawer
  20. {
  21. public override string ClassName { get { return "MarkLineData"; } }
  22. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  23. {
  24. base.OnGUI(pos, prop, label);
  25. if (MakeComponentFoldout(prop, "", true))
  26. {
  27. ++EditorGUI.indentLevel;
  28. var type = (MarkLineType) (prop.FindPropertyRelative("m_Type")).enumValueIndex;
  29. var group = prop.FindPropertyRelative("m_Group").intValue;
  30. PropertyField(prop, "m_Type");
  31. PropertyField(prop, "m_Name");
  32. switch (type)
  33. {
  34. case MarkLineType.None:
  35. PropertyField(prop, "m_XPosition");
  36. PropertyField(prop, "m_YPosition");
  37. PropertyField(prop, "m_XValue");
  38. PropertyField(prop, "m_YValue");
  39. break;
  40. case MarkLineType.Min:
  41. case MarkLineType.Max:
  42. case MarkLineType.Average:
  43. case MarkLineType.Median:
  44. PropertyField(prop, "m_Dimension");
  45. break;
  46. }
  47. PropertyField(prop, "m_Group");
  48. if (group > 0 && type == MarkLineType.None) PropertyField(prop, "m_ZeroPosition");
  49. PropertyField(prop, "m_LineStyle");
  50. PropertyField(prop, "m_StartSymbol");
  51. PropertyField(prop, "m_EndSymbol");
  52. PropertyField(prop, "m_Label");
  53. --EditorGUI.indentLevel;
  54. }
  55. }
  56. }
  57. }