2019-10-22 04:09:04 +08:00
|
|
|
|
/******************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
using UnityEditor;
|
2019-07-03 18:45:48 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-07-13 16:38:38 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(AxisLabel), true)]
|
2019-07-03 18:45:48 +08:00
|
|
|
|
public class AxisLabelDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
private Dictionary<string, bool> m_AxisLabelToggle = new Dictionary<string, bool>();
|
2019-07-03 18:45:48 +08:00
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
SerializedProperty show = prop.FindPropertyRelative("m_Show");
|
2019-09-23 19:09:56 +08:00
|
|
|
|
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
2019-07-03 18:45:48 +08:00
|
|
|
|
SerializedProperty m_Inside = prop.FindPropertyRelative("m_Inside");
|
|
|
|
|
|
SerializedProperty m_Interval = prop.FindPropertyRelative("m_Interval");
|
|
|
|
|
|
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
|
|
|
|
|
SerializedProperty m_Margin = prop.FindPropertyRelative("m_Margin");
|
|
|
|
|
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
|
|
|
|
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
|
|
|
|
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
2019-10-26 05:02:32 +08:00
|
|
|
|
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
2020-01-26 22:34:57 +08:00
|
|
|
|
SerializedProperty m_TextLimit = prop.FindPropertyRelative("m_TextLimit");
|
2019-07-03 18:45:48 +08:00
|
|
|
|
|
2019-09-23 19:09:56 +08:00
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLabelToggle, prop, "Axis Label", show, false);
|
2019-07-03 18:45:48 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-23 19:09:56 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
2019-07-03 18:45:48 +08:00
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Inside);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Interval);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Rotate);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Margin);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Color);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FontSize);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-23 19:09:56 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Formatter);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-10-26 05:02:32 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_ForceENotation);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2020-01-26 22:34:57 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_TextLimit);
|
|
|
|
|
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextLimit);
|
2019-07-03 18:45:48 +08:00
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
float height = 0;
|
2019-09-23 19:09:56 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_AxisLabelToggle, prop))
|
2019-07-03 18:45:48 +08:00
|
|
|
|
{
|
2020-01-26 22:34:57 +08:00
|
|
|
|
height += 10 * EditorGUIUtility.singleLineHeight + 9 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextLimit"));
|
2019-07-03 18:45:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|