2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(BarChart.Bar), true)]
|
|
|
|
|
|
public class BarDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
2019-05-30 00:20:00 +08:00
|
|
|
|
SerializedProperty m_InSameBar;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
SerializedProperty m_BarWidth;
|
|
|
|
|
|
SerializedProperty m_Space;
|
|
|
|
|
|
bool m_BarModuleToggle = true;
|
|
|
|
|
|
|
|
|
|
|
|
private void InitProperty(SerializedProperty prop)
|
|
|
|
|
|
{
|
2019-05-30 00:20:00 +08:00
|
|
|
|
m_InSameBar = prop.FindPropertyRelative("m_InSameBar");
|
2019-05-11 04:33:54 +08:00
|
|
|
|
m_BarWidth = prop.FindPropertyRelative("m_BarWidth");
|
|
|
|
|
|
m_Space = prop.FindPropertyRelative("m_Space");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitProperty(prop);
|
|
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
|
|
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_BarModuleToggle, "Bar");
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
|
|
|
|
|
|
if (m_BarModuleToggle)
|
|
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
2019-05-30 00:20:00 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_InSameBar);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BarWidth);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Space);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_BarModuleToggle)
|
2019-05-30 00:20:00 +08:00
|
|
|
|
return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
else
|
|
|
|
|
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|