ProgressBarEditor.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEditor;
  2. using XCharts.Runtime;
  3. namespace XCharts.Editor
  4. {
  5. [CustomEditor(typeof(ProgressBar), false)]
  6. public class ProgressBarEditor : UnityEditor.Editor
  7. {
  8. [MenuItem("XCharts/ProgressBar", priority = 200)]
  9. [MenuItem("GameObject/XCharts/ProgressBar", priority = 200)]
  10. public static void AddPyramidChart()
  11. {
  12. XChartsEditor.AddChart<ProgressBar>("ProgressBar");
  13. }
  14. protected SerializedProperty m_Script;
  15. protected SerializedProperty m_Value;
  16. protected SerializedProperty m_BackgroundColor;
  17. protected SerializedProperty m_StartColor;
  18. protected SerializedProperty m_EndColor;
  19. protected SerializedProperty m_CornerRadius;
  20. protected virtual void OnEnable()
  21. {
  22. m_Script = serializedObject.FindProperty("m_Script");
  23. m_Value = serializedObject.FindProperty("m_Value");
  24. m_BackgroundColor = serializedObject.FindProperty("m_BackgroundColor");
  25. m_StartColor = serializedObject.FindProperty("m_StartColor");
  26. m_EndColor = serializedObject.FindProperty("m_EndColor");
  27. m_CornerRadius = serializedObject.FindProperty("m_CornerRadius");
  28. }
  29. public override void OnInspectorGUI()
  30. {
  31. serializedObject.Update();
  32. OnStartInspectorGUI();
  33. serializedObject.ApplyModifiedProperties();
  34. }
  35. protected virtual void OnStartInspectorGUI()
  36. {
  37. EditorGUILayout.PropertyField(m_Script);
  38. EditorGUILayout.PropertyField(m_BackgroundColor);
  39. EditorGUILayout.PropertyField(m_StartColor);
  40. EditorGUILayout.PropertyField(m_EndColor);
  41. EditorGUILayout.PropertyField(m_Value);
  42. EditorGUILayout.PropertyField(m_CornerRadius);
  43. }
  44. }
  45. }