Files
XCharts/Editor/Widgets/ProgressBarEditor.cs

51 lines
1.8 KiB
C#
Raw Normal View History

2021-11-23 13:20:07 +08:00
using UnityEditor;
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
{
2022-03-09 07:26:15 +08:00
[CustomEditor(typeof(ProgressBar), false)]
public class ProgressBarEditor : UnityEditor.Editor
2021-11-23 13:20:07 +08:00
{
[MenuItem("XCharts/ProgressBar", priority = 200)]
[MenuItem("GameObject/XCharts/ProgressBar", priority = 200)]
public static void AddPyramidChart()
{
2022-03-09 07:26:15 +08:00
XChartsEditor.AddChart<ProgressBar>("ProgressBar");
2021-11-23 13:20:07 +08:00
}
protected SerializedProperty m_Script;
protected SerializedProperty m_Value;
protected SerializedProperty m_BackgroundColor;
protected SerializedProperty m_StartColor;
protected SerializedProperty m_EndColor;
protected SerializedProperty m_CornerRadius;
protected virtual void OnEnable()
{
m_Script = serializedObject.FindProperty("m_Script");
m_Value = serializedObject.FindProperty("m_Value");
m_BackgroundColor = serializedObject.FindProperty("m_BackgroundColor");
m_StartColor = serializedObject.FindProperty("m_StartColor");
m_EndColor = serializedObject.FindProperty("m_EndColor");
m_CornerRadius = serializedObject.FindProperty("m_CornerRadius");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
OnStartInspectorGUI();
serializedObject.ApplyModifiedProperties();
}
protected virtual void OnStartInspectorGUI()
{
EditorGUILayout.PropertyField(m_Script);
EditorGUILayout.PropertyField(m_BackgroundColor);
EditorGUILayout.PropertyField(m_StartColor);
EditorGUILayout.PropertyField(m_EndColor);
EditorGUILayout.PropertyField(m_Value);
EditorGUILayout.PropertyField(m_CornerRadius);
}
}
}