增加AxisLine配置坐标轴轴线和箭头

This commit is contained in:
monitor1394
2019-07-09 22:20:50 +08:00
parent 530b0228a7
commit d3f7980a6d
5 changed files with 150 additions and 26 deletions

View File

@@ -0,0 +1,51 @@
using UnityEditor;
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(Axis.AxisLine), true)]
public class AxisLineDrawer : PropertyDrawer
{
private bool m_AxisLineToggle = false;
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_Symbol = prop.FindPropertyRelative("m_Symbol");
SerializedProperty m_SymbolWidth = prop.FindPropertyRelative("m_SymbolWidth");
SerializedProperty m_SymbolHeight = prop.FindPropertyRelative("m_SymbolHeight");
SerializedProperty m_SymbolOffset = prop.FindPropertyRelative("m_SymbolOffset");
SerializedProperty m_SymbolDent = prop.FindPropertyRelative("m_SymbolDent");
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisLineToggle, "Axis Line", show, false);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
if (m_AxisLineToggle)
{
++EditorGUI.indentLevel;
EditorGUI.PropertyField(drawRect, m_Symbol);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SymbolWidth);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SymbolHeight);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SymbolOffset);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SymbolDent);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
--EditorGUI.indentLevel;
}
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
if (m_AxisLineToggle)
{
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
}
return height;
}
}
}