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-06-30 18:34:09 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-07-13 16:38:38 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(AxisSplitArea), true)]
|
2019-06-30 18:34:09 +08:00
|
|
|
|
public class AxisSplitAreaDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
private bool m_ColorFoldout = false;
|
|
|
|
|
|
private int m_ColorSize = 0;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
private Dictionary<string, bool> m_SplitAreaToggle = new Dictionary<string, bool>();
|
2019-06-30 18:34:09 +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");
|
|
|
|
|
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
|
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SplitAreaToggle, prop, "Split Area", show, false);
|
2019-06-30 18:34:09 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_SplitAreaToggle, prop))
|
2019-06-30 18:34:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
m_ColorFoldout = EditorGUI.Foldout(drawRect, m_ColorFoldout, "Color");
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
drawRect.width = pos.width;
|
|
|
|
|
|
if (m_ColorFoldout)
|
|
|
|
|
|
{
|
|
|
|
|
|
ChartEditorHelper.MakeList(ref drawRect, ref m_ColorSize, m_Color);
|
|
|
|
|
|
}
|
|
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
float height = 0;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_SplitAreaToggle, prop))
|
2019-06-30 18:34:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
if (m_ColorFoldout)
|
|
|
|
|
|
{
|
|
|
|
|
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_Color");
|
|
|
|
|
|
int num = m_Data.arraySize + 1;
|
|
|
|
|
|
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
height += EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|