2019-10-22 04:09:04 +08:00
|
|
|
|
/******************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using UnityEditor;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(Grid), true)]
|
|
|
|
|
|
public class GridDrawer : PropertyDrawer
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
private bool m_GridModuleToggle = false;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
SerializedProperty m_Show = prop.FindPropertyRelative("m_Show");
|
2019-05-11 04:33:54 +08:00
|
|
|
|
SerializedProperty m_Left = prop.FindPropertyRelative("m_Left");
|
|
|
|
|
|
SerializedProperty m_Right = prop.FindPropertyRelative("m_Right");
|
|
|
|
|
|
SerializedProperty m_Top = prop.FindPropertyRelative("m_Top");
|
|
|
|
|
|
SerializedProperty m_Bottom = prop.FindPropertyRelative("m_Bottom");
|
2019-08-01 23:49:30 +08:00
|
|
|
|
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
2019-08-01 23:49:30 +08:00
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_GridModuleToggle, "Grid",m_Show);
|
|
|
|
|
|
EditorGUI.LabelField(drawRect, "Grid", EditorStyles.boldLabel);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-01 23:49:30 +08:00
|
|
|
|
if (m_GridModuleToggle)
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Left);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Right);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Top);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Bottom);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-01 23:49:30 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
2019-08-01 23:49:30 +08:00
|
|
|
|
if (m_GridModuleToggle)
|
|
|
|
|
|
return 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
else
|
|
|
|
|
|
return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|