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-29 00:25:10 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(SerieLabel), true)]
|
|
|
|
|
|
public class SerieLabelDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
private Dictionary<string, bool> m_SerieLabelToggle = new Dictionary<string, bool>();
|
2019-07-29 00:25:10 +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_Position = prop.FindPropertyRelative("m_Position");
|
2019-09-20 12:38:45 +08:00
|
|
|
|
SerializedProperty m_Formatter = prop.FindPropertyRelative("m_Formatter");
|
2019-09-25 09:44:53 +08:00
|
|
|
|
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
2019-11-30 21:24:04 +08:00
|
|
|
|
SerializedProperty m_Margin = prop.FindPropertyRelative("m_Margin");
|
2019-07-29 00:25:10 +08:00
|
|
|
|
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
2019-08-20 09:40:19 +08:00
|
|
|
|
SerializedProperty m_PaddingLeftRight = prop.FindPropertyRelative("m_PaddingLeftRight");
|
|
|
|
|
|
SerializedProperty m_PaddingTopBottom = prop.FindPropertyRelative("m_PaddingTopBottom");
|
2019-07-29 00:25:10 +08:00
|
|
|
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
2019-08-16 00:13:01 +08:00
|
|
|
|
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
|
2019-08-20 09:40:19 +08:00
|
|
|
|
SerializedProperty m_BackgroundWidth = prop.FindPropertyRelative("m_BackgroundWidth");
|
|
|
|
|
|
SerializedProperty m_BackgroundHeight = prop.FindPropertyRelative("m_BackgroundHeight");
|
2019-07-29 00:25:10 +08:00
|
|
|
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
|
|
|
|
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
|
|
|
|
|
SerializedProperty m_Line = prop.FindPropertyRelative("m_Line");
|
2019-10-05 18:23:06 +08:00
|
|
|
|
SerializedProperty m_LineType = prop.FindPropertyRelative("m_LineType");
|
|
|
|
|
|
SerializedProperty m_LineColor = prop.FindPropertyRelative("m_LineColor");
|
2019-07-29 00:25:10 +08:00
|
|
|
|
SerializedProperty m_LineWidth = prop.FindPropertyRelative("m_LineWidth");
|
|
|
|
|
|
SerializedProperty m_LineLength1 = prop.FindPropertyRelative("m_LineLength1");
|
|
|
|
|
|
SerializedProperty m_LineLength2 = prop.FindPropertyRelative("m_LineLength2");
|
2019-09-06 09:11:46 +08:00
|
|
|
|
SerializedProperty m_Border = prop.FindPropertyRelative("m_Border");
|
|
|
|
|
|
SerializedProperty m_BorderWidth = prop.FindPropertyRelative("m_BorderWidth");
|
|
|
|
|
|
SerializedProperty m_BorderColor = prop.FindPropertyRelative("m_BorderColor");
|
2019-10-26 05:02:32 +08:00
|
|
|
|
SerializedProperty m_ForceENotation = prop.FindPropertyRelative("m_ForceENotation");
|
2019-07-29 00:25:10 +08:00
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SerieLabelToggle, prop, null, show, false);
|
2019-07-29 00:25:10 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_SerieLabelToggle, prop))
|
2019-07-29 00:25:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Position);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-25 09:44:53 +08:00
|
|
|
|
|
2020-03-26 09:13:46 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Offset);
|
|
|
|
|
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
|
2019-09-25 09:44:53 +08:00
|
|
|
|
|
2019-11-30 21:24:04 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Margin);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-09-25 09:44:53 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Formatter);
|
2019-07-29 00:25:10 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2020-03-26 09:13:46 +08:00
|
|
|
|
|
2019-07-29 00:25:10 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Color);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-16 00:13:01 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-20 09:40:19 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BackgroundWidth);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BackgroundHeight);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-07-29 00:25:10 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Rotate);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-20 09:40:19 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_PaddingLeftRight);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_PaddingTopBottom);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-07-29 00:25:10 +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-09-06 09:11:46 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Border);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BorderWidth);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_BorderColor);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-07-29 00:25:10 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Line);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-10-05 18:23:06 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_LineType);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_LineColor);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-07-29 00:25:10 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_LineWidth);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_LineLength1);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_LineLength2);
|
|
|
|
|
|
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;
|
2019-07-29 00:25:10 +08:00
|
|
|
|
--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_SerieLabelToggle, prop))
|
2019-07-29 00:25:10 +08:00
|
|
|
|
{
|
2020-03-26 09:13:46 +08:00
|
|
|
|
height += 23 * EditorGUIUtility.singleLineHeight + 22 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Offset"));
|
2019-07-29 08:01:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2019-07-29 00:25:10 +08:00
|
|
|
|
height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|