2021-01-11 08:54:28 +08:00
|
|
|
|
/************************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 - 2021 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/************************************************/
|
2019-10-22 04:09:04 +08:00
|
|
|
|
|
|
|
|
|
|
using UnityEditor;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(Series), true)]
|
|
|
|
|
|
public class SeriesDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
|
|
|
|
|
private bool m_SeriesModuleToggle = false;
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
SerializedProperty m_Series = prop.FindPropertyRelative("m_Series");
|
2021-01-17 11:44:47 +08:00
|
|
|
|
m_SeriesModuleToggle = ChartEditorHelper.MakeListWithFoldout(ref drawRect,
|
|
|
|
|
|
m_Series, m_SeriesModuleToggle, true, true);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
|
|
|
|
|
float height = 0;
|
|
|
|
|
|
if (m_SeriesModuleToggle)
|
|
|
|
|
|
{
|
|
|
|
|
|
SerializedProperty m_Data = prop.FindPropertyRelative("m_Series");
|
|
|
|
|
|
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
for (int i = 0; i < m_Data.arraySize; i++)
|
|
|
|
|
|
{
|
2021-01-11 08:54:28 +08:00
|
|
|
|
height += EditorGUI.GetPropertyHeight(m_Data.GetArrayElementAtIndex(i)) + EditorGUIUtility.standardVerticalSpacing;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|