2019-08-04 15:24:31 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEditor;
|
2019-06-29 07:22:57 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
2019-07-13 16:38:38 +08:00
|
|
|
|
[CustomPropertyDrawer(typeof(AxisName), true)]
|
2019-06-29 07:22:57 +08:00
|
|
|
|
public class AxisNameDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
private Dictionary<string, bool> m_AxisNameToggle = new Dictionary<string, bool>();
|
2019-06-29 07:22:57 +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_Name = prop.FindPropertyRelative("m_Name");
|
|
|
|
|
|
SerializedProperty m_Location = prop.FindPropertyRelative("m_Location");
|
2019-08-22 19:17:00 +08:00
|
|
|
|
SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset");
|
2019-06-29 07:22:57 +08:00
|
|
|
|
SerializedProperty m_Rotate = prop.FindPropertyRelative("m_Rotate");
|
|
|
|
|
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
|
|
|
|
|
SerializedProperty m_FontSize = prop.FindPropertyRelative("m_FontSize");
|
2019-07-03 18:45:48 +08:00
|
|
|
|
SerializedProperty m_FontStyle = prop.FindPropertyRelative("m_FontStyle");
|
2019-06-29 07:22:57 +08:00
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisNameToggle, prop, "Axis Name", show, false);
|
2019-06-29 07:22:57 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_AxisNameToggle, prop))
|
2019-06-29 07:22:57 +08:00
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Name);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Location);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-22 19:17:00 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Offset);
|
|
|
|
|
|
drawRect.y += EditorGUI.GetPropertyHeight(m_Offset);
|
|
|
|
|
|
// EditorGUI.LabelField(drawRect, "Offset");
|
|
|
|
|
|
// var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15;
|
|
|
|
|
|
// var tempWidth = (pos.width - startX + 35) / 2;
|
|
|
|
|
|
// var xRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height);
|
|
|
|
|
|
// var yRect = new Rect(xRect.x + tempWidth - 20, drawRect.y, tempWidth, drawRect.height);
|
|
|
|
|
|
// var x = EditorGUI.FloatField(xRect, m_Offset.vector2Value.x);
|
|
|
|
|
|
// var y = EditorGUI.FloatField(yRect, m_Offset.vector2Value.y);
|
|
|
|
|
|
// m_Offset.vector2Value = new Vector2(x,y);
|
|
|
|
|
|
// drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-06-29 07:22:57 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Rotate);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-07-03 18:45:48 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Color);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-06-29 07:22:57 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FontSize);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-07-03 18:45:48 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_FontStyle);
|
2019-06-29 07:22:57 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
--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_AxisNameToggle, prop))
|
2019-06-29 07:22:57 +08:00
|
|
|
|
{
|
2019-07-03 18:45:48 +08:00
|
|
|
|
height += 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
|
2019-06-29 07:22:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
return height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|