VisualMapEditor.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Editor
  5. {
  6. [ComponentEditor(typeof(VisualMap))]
  7. public class VisualMapEditor : MainComponentEditor<VisualMap>
  8. {
  9. public override void OnInspectorGUI()
  10. {
  11. ++EditorGUI.indentLevel;
  12. var type = (VisualMap.Type) baseProperty.FindPropertyRelative("m_Type").enumValueIndex;
  13. var isPiece = type == VisualMap.Type.Piecewise;
  14. PropertyField("m_Type");
  15. PropertyField("m_SerieIndex");
  16. PropertyField("m_AutoMinMax");
  17. PropertyField("m_Min");
  18. PropertyField("m_Max");
  19. PropertyField("m_SplitNumber");
  20. PropertyField("m_Dimension");
  21. PropertyField("m_WorkOnLine");
  22. PropertyField("m_WorkOnArea");
  23. PropertyField("m_ShowUI");
  24. if (baseProperty.FindPropertyRelative("m_ShowUI").boolValue)
  25. {
  26. PropertyField("m_SelectedMode");
  27. PropertyTwoFiled("m_Range");
  28. PropertyTwoFiled("m_Text");
  29. PropertyTwoFiled("m_TextGap");
  30. PropertyField("m_HoverLink");
  31. PropertyField("m_Calculable");
  32. PropertyField("m_ItemWidth");
  33. PropertyField("m_ItemHeight");
  34. if (isPiece) PropertyField("m_ItemGap");
  35. PropertyField("m_BorderWidth");
  36. PropertyField("m_Orient");
  37. PropertyField("m_Location");
  38. }
  39. PropertyListField("m_OutOfRange");
  40. PropertyListField("m_InRange");
  41. --EditorGUI.indentLevel;
  42. }
  43. }
  44. [CustomPropertyDrawer(typeof(VisualMapRange), true)]
  45. public class VisualMapRangeDrawer : BasePropertyDrawer
  46. {
  47. public override string ClassName { get { return "Range"; } }
  48. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  49. {
  50. base.OnGUI(pos, prop, label);
  51. if (MakeFoldout(prop, "m_Color"))
  52. {
  53. ++EditorGUI.indentLevel;
  54. PropertyField(prop, "m_Min");
  55. PropertyField(prop, "m_Max");
  56. PropertyField(prop, "m_Label");
  57. PropertyField(prop, "m_Color");
  58. --EditorGUI.indentLevel;
  59. }
  60. }
  61. }
  62. }