/******************************************/ /* */ /* Copyright (c) 2018 monitor1394 */ /* https://github.com/monitor1394 */ /* */ /******************************************/ using System.Collections.Generic; using UnityEditor; using UnityEngine; namespace XCharts { [CustomPropertyDrawer(typeof(LineArrow), true)] public class LineArrowStyleDrawer : PropertyDrawer { private Dictionary m_LineArrowToggle = new Dictionary(); 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"); SerializedProperty m_Width = prop.FindPropertyRelative("m_Width"); SerializedProperty m_Height = prop.FindPropertyRelative("m_Height"); SerializedProperty m_Offset = prop.FindPropertyRelative("m_Offset"); SerializedProperty m_Dent = prop.FindPropertyRelative("m_Dent"); ChartEditorHelper.MakeFoldout(ref drawRect, ref m_LineArrowToggle, prop, "Line Arrow", show, false); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; if (ChartEditorHelper.IsToggle(m_LineArrowToggle, prop)) { ++EditorGUI.indentLevel; EditorGUI.PropertyField(drawRect, m_Position); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Width); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Height); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Offset); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; EditorGUI.PropertyField(drawRect, m_Dent); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; --EditorGUI.indentLevel; } } public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { float height = 0; if (ChartEditorHelper.IsToggle(m_LineArrowToggle, prop)) { height += 6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing; } else { height += 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; } return height; } } }