AxisEditor.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. using UnityEditor;
  2. using UnityEngine;
  3. using XCharts.Runtime;
  4. namespace XCharts.Editor
  5. {
  6. [ComponentEditor(typeof(Axis))]
  7. public class AxisEditor : MainComponentEditor<Axis>
  8. {
  9. public override void OnInspectorGUI()
  10. {
  11. var m_Type = baseProperty.FindPropertyRelative("m_Type");
  12. var m_LogBase = baseProperty.FindPropertyRelative("m_LogBase");
  13. var m_MinMaxType = baseProperty.FindPropertyRelative("m_MinMaxType");
  14. var type = (Axis.AxisType)m_Type.enumValueIndex;
  15. EditorGUI.indentLevel++;
  16. if (component is ParallelAxis)
  17. {
  18. PropertyField("m_ParallelIndex");
  19. }
  20. else if (!(component is SingleAxis))
  21. {
  22. PropertyField("m_GridIndex");
  23. PropertyField("m_PolarIndex");
  24. }
  25. PropertyField("m_Type");
  26. PropertyField("m_Position");
  27. PropertyField("m_Offset");
  28. if (type == Axis.AxisType.Log)
  29. {
  30. PropertyField("m_LogBaseE");
  31. EditorGUI.BeginChangeCheck();
  32. PropertyField("m_LogBase");
  33. if (m_LogBase.floatValue <= 0 || m_LogBase.floatValue == 1)
  34. {
  35. m_LogBase.floatValue = 10;
  36. }
  37. EditorGUI.EndChangeCheck();
  38. }
  39. if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
  40. {
  41. PropertyField("m_MinMaxType");
  42. Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
  43. switch (minMaxType)
  44. {
  45. case Axis.AxisMinMaxType.Default:
  46. break;
  47. case Axis.AxisMinMaxType.MinMax:
  48. break;
  49. case Axis.AxisMinMaxType.Custom:
  50. EditorGUI.indentLevel++;
  51. PropertyField("m_Min");
  52. PropertyField("m_Max");
  53. EditorGUI.indentLevel--;
  54. break;
  55. }
  56. PropertyField("m_CeilRate");
  57. if (type == Axis.AxisType.Value)
  58. {
  59. PropertyField("m_Inverse");
  60. }
  61. }
  62. PropertyField("m_SplitNumber");
  63. if (type == Axis.AxisType.Category)
  64. {
  65. PropertyField("m_MaxCache");
  66. PropertyField("m_BoundaryGap");
  67. }
  68. else
  69. {
  70. PropertyField("m_Interval");
  71. }
  72. DrawExtendeds();
  73. if (type != Axis.AxisType.Category)
  74. {
  75. PropertyField("m_Animation");
  76. }
  77. PropertyField("m_AxisLine");
  78. PropertyField("m_AxisName");
  79. PropertyField("m_AxisTick");
  80. PropertyField("m_AxisLabel");
  81. PropertyField("m_SplitLine");
  82. PropertyField("m_SplitArea");
  83. PropertyField("m_IndicatorLabel");
  84. if (type != Axis.AxisType.Category)
  85. {
  86. PropertyField("m_MinorTick");
  87. PropertyField("m_MinorSplitLine");
  88. }
  89. PropertyListField("m_Icons", true);
  90. if (type == Axis.AxisType.Category)
  91. {
  92. PropertyListField("m_Data", true, new HeaderMenuInfo("Import ECharts Axis Data", () =>
  93. {
  94. PraseExternalDataEditor.UpdateData(chart, null, component as Axis, false);
  95. PraseExternalDataEditor.ShowWindow();
  96. }));
  97. }
  98. EditorGUI.indentLevel--;
  99. }
  100. }
  101. [ComponentEditor(typeof(XAxis))]
  102. public class XAxisEditor : AxisEditor { }
  103. [ComponentEditor(typeof(YAxis))]
  104. public class YAxisEditor : AxisEditor { }
  105. [ComponentEditor(typeof(SingleAxis))]
  106. public class SingleAxisEditor : AxisEditor
  107. {
  108. protected override void DrawExtendeds()
  109. {
  110. base.DrawExtendeds();
  111. PropertyField("m_Orient");
  112. PropertyField("m_Left");
  113. PropertyField("m_Right");
  114. PropertyField("m_Top");
  115. PropertyField("m_Bottom");
  116. PropertyField("m_Width");
  117. PropertyField("m_Height");
  118. }
  119. }
  120. [ComponentEditor(typeof(AngleAxis))]
  121. public class AngleAxisEditor : AxisEditor
  122. {
  123. protected override void DrawExtendeds()
  124. {
  125. base.DrawExtendeds();
  126. PropertyField("m_StartAngle");
  127. PropertyField("m_Clockwise");
  128. }
  129. }
  130. [ComponentEditor(typeof(RadiusAxis))]
  131. public class RadiusAxisEditor : AxisEditor { }
  132. [ComponentEditor(typeof(ParallelAxis))]
  133. public class ParallelAxisEditor : AxisEditor { }
  134. [CustomPropertyDrawer(typeof(AxisLabel), true)]
  135. public class AxisLabelDrawer : BasePropertyDrawer
  136. {
  137. public override string ClassName { get { return "AxisLabel"; } }
  138. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  139. {
  140. base.OnGUI(pos, prop, label);
  141. if (MakeComponentFoldout(prop, "m_Show", true))
  142. {
  143. ++EditorGUI.indentLevel;
  144. PropertyField(prop, "m_Inside");
  145. PropertyField(prop, "m_Interval");
  146. PropertyField(prop, "m_ShowAsPositiveNumber");
  147. PropertyField(prop, "m_OnZero");
  148. PropertyField(prop, "m_ShowStartLabel");
  149. PropertyField(prop, "m_ShowEndLabel");
  150. PropertyField(prop, "m_Rotate");
  151. PropertyField(prop, "m_Offset");
  152. PropertyField(prop, "m_Distance");
  153. PropertyField(prop, "m_Formatter");
  154. PropertyField(prop, "m_NumericFormatter");
  155. PropertyField(prop, "m_Width");
  156. PropertyField(prop, "m_Height");
  157. PropertyField(prop, "m_Icon");
  158. PropertyField(prop, "m_Background");
  159. PropertyField(prop, "m_TextStyle");
  160. PropertyField(prop, "m_TextPadding");
  161. PropertyField(prop, "m_TextLimit");
  162. --EditorGUI.indentLevel;
  163. }
  164. }
  165. }
  166. [CustomPropertyDrawer(typeof(AxisName), true)]
  167. public class AxisNameDrawer : BasePropertyDrawer
  168. {
  169. public override string ClassName { get { return "AxisName"; } }
  170. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  171. {
  172. base.OnGUI(pos, prop, label);
  173. if (MakeComponentFoldout(prop, "m_Show", true))
  174. {
  175. ++EditorGUI.indentLevel;
  176. PropertyField(prop, "m_Name");
  177. PropertyField(prop, "m_OnZero");
  178. PropertyField(prop, "m_LabelStyle");
  179. --EditorGUI.indentLevel;
  180. }
  181. }
  182. }
  183. [CustomPropertyDrawer(typeof(AxisSplitArea), true)]
  184. public class AxisSplitAreaDrawer : BasePropertyDrawer
  185. {
  186. public override string ClassName { get { return "SplitArea"; } }
  187. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  188. {
  189. base.OnGUI(pos, prop, label);
  190. if (MakeComponentFoldout(prop, "m_Show", true))
  191. {
  192. ++EditorGUI.indentLevel;
  193. PropertyField(prop, "m_Color");
  194. --EditorGUI.indentLevel;
  195. }
  196. }
  197. }
  198. [CustomPropertyDrawer(typeof(AxisAnimation), true)]
  199. public class AxisAnimationDrawer : BasePropertyDrawer
  200. {
  201. public override string ClassName { get { return "Animation"; } }
  202. public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
  203. {
  204. base.OnGUI(pos, prop, label);
  205. if (MakeComponentFoldout(prop, "m_Show", true))
  206. {
  207. ++EditorGUI.indentLevel;
  208. PropertyField(prop, "m_UnscaledTime");
  209. PropertyField(prop, "m_Duration");
  210. --EditorGUI.indentLevel;
  211. }
  212. }
  213. }
  214. }