/******************************************/ /* */ /* Copyright (c) 2018 monitor1394 */ /* https://github.com/monitor1394 */ /* */ /******************************************/ using UnityEditor; using UnityEngine; namespace XCharts { [CustomPropertyDrawer(typeof(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"); SerializedProperty m_Width = prop.FindPropertyRelative("m_Width"); 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.PropertyField(drawRect, m_Width); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; --EditorGUI.indentLevel; } } public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { float height = 0; if (m_AxisTickToggle) { height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; } return height; } } }