using UnityEditor; using UnityEngine; namespace XCharts { [CustomPropertyDrawer(typeof(Axis.AxisTick), true)] public class AxisTickDrawer : PropertyDrawer { private bool m_AxisTickToggle = 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_AlignWithLabel = prop.FindPropertyRelative("m_AlignWithLabel"); SerializedProperty m_Inside = prop.FindPropertyRelative("m_Inside"); SerializedProperty m_Length = prop.FindPropertyRelative("m_Length"); ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AxisTickToggle, "Axis Tick", show, false); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; if (m_AxisTickToggle) { ++EditorGUI.indentLevel; EditorGUI.PropertyField(drawRect, m_AlignWithLabel); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Inside); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Length); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; --EditorGUI.indentLevel; } } public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { float height = 0; if (m_AxisTickToggle) { height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; } return height; } } }