2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(Tooltip), true)]
|
|
|
|
|
|
public class TooltipDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
private bool m_TooltipModuleToggle = false;
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
2019-07-18 09:42:36 +08:00
|
|
|
|
SerializedProperty type = prop.FindPropertyRelative("m_Type");
|
2019-09-23 09:23:51 +08:00
|
|
|
|
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
2019-09-19 09:06:04 +08:00
|
|
|
|
SerializedProperty m_FixedWidth = prop.FindPropertyRelative("m_FixedWidth");
|
|
|
|
|
|
SerializedProperty m_FixedHeight = prop.FindPropertyRelative("m_FixedHeight");
|
|
|
|
|
|
SerializedProperty m_MinWidth = prop.FindPropertyRelative("m_MinWidth");
|
|
|
|
|
|
SerializedProperty m_MinHeight = prop.FindPropertyRelative("m_MinHeight");
|
2019-09-23 09:50:57 +08:00
|
|
|
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
|
|
|
|
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_TooltipModuleToggle, "Tooltip", show);
|
2019-05-29 09:53:30 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
if (m_TooltipModuleToggle)
|
|
|
|
|
|
{
|
2019-07-18 09:42:36 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, type);
|
2019-05-29 09:53:30 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-23 09:23:51 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Formatter);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-19 09:06:04 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FixedWidth);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FixedHeight);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_MinWidth);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_MinHeight);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-23 09:50:57 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FontSize);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-05-29 09:53:30 +08:00
|
|
|
|
}
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
2019-06-21 09:34:33 +08:00
|
|
|
|
if (m_TooltipModuleToggle)
|
2019-09-23 09:50:57 +08:00
|
|
|
|
return 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
2019-05-29 09:53:30 +08:00
|
|
|
|
else
|
2019-07-18 09:42:36 +08:00
|
|
|
|
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|