2019-08-04 15:24:31 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(AreaStyle), true)]
|
|
|
|
|
|
public class AreaStyleDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
private Dictionary<string, bool> m_AreaStyleToggle = new Dictionary<string, bool>();
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
|
|
|
|
|
SerializedProperty m_Origin = prop.FindPropertyRelative("m_Origin");
|
|
|
|
|
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
|
|
|
|
|
SerializedProperty m_ToColor = prop.FindPropertyRelative("m_ToColor");
|
2019-10-09 18:54:58 +08:00
|
|
|
|
SerializedProperty m_HighlightColor = prop.FindPropertyRelative("m_HighlightColor");
|
|
|
|
|
|
SerializedProperty m_HighlightToColor = prop.FindPropertyRelative("m_HighlightToColor");
|
2019-08-04 15:24:31 +08:00
|
|
|
|
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
|
2019-10-09 18:54:58 +08:00
|
|
|
|
SerializedProperty m_TooltipHighlight = prop.FindPropertyRelative("m_TooltipHighlight");
|
2019-08-04 15:24:31 +08:00
|
|
|
|
|
|
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AreaStyleToggle, prop, "Area Style", show, false);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
if (ChartEditorHelper.IsToggle(m_AreaStyleToggle, prop))
|
|
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Origin);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Color);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_ToColor);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-10-09 18:54:58 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_HighlightColor);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_HighlightToColor);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Opacity);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-10-09 18:54:58 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_TooltipHighlight);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
float height = 0;
|
|
|
|
|
|
if (ChartEditorHelper.IsToggle(m_AreaStyleToggle, prop))
|
|
|
|
|
|
{
|
2019-10-09 18:54:58 +08:00
|
|
|
|
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|