2019-10-22 04:09:04 +08:00
|
|
|
|
/******************************************/
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/* Copyright (c) 2018 monitor1394 */
|
|
|
|
|
|
/* https://github.com/monitor1394 */
|
|
|
|
|
|
/* */
|
|
|
|
|
|
/******************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
using UnityEditor;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XCharts
|
|
|
|
|
|
{
|
|
|
|
|
|
[CustomPropertyDrawer(typeof(Radar.Indicator), true)]
|
|
|
|
|
|
public class RadarIndicatorDrawer : PropertyDrawer
|
|
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
private Dictionary<string, bool> m_RadarModuleToggle = new Dictionary<string, bool>();
|
2019-05-11 04:33:54 +08:00
|
|
|
|
|
|
|
|
|
|
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
2019-08-04 15:24:31 +08:00
|
|
|
|
SerializedProperty m_Name = prop.FindPropertyRelative("m_Name");
|
|
|
|
|
|
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
|
|
|
|
|
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
2019-11-05 18:58:32 +08:00
|
|
|
|
SerializedProperty m_TextStyle = prop.FindPropertyRelative("m_TextStyle");
|
2019-05-11 04:33:54 +08:00
|
|
|
|
Rect drawRect = pos;
|
|
|
|
|
|
float defaultLabelWidth = EditorGUIUtility.labelWidth;
|
|
|
|
|
|
float defaultFieldWidth = EditorGUIUtility.fieldWidth;
|
|
|
|
|
|
drawRect.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
|
|
|
2019-08-04 15:24:31 +08:00
|
|
|
|
int index = ChartEditorHelper.GetIndexFromPath(prop);
|
|
|
|
|
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_RadarModuleToggle, prop, "Indicator " + index, m_Name, false);
|
2019-05-11 04:33:54 +08:00
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-11-05 18:58:32 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
|
|
|
|
|
++EditorGUI.indentLevel;
|
2019-06-21 09:34:33 +08:00
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Name);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-08-04 15:24:31 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Min);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_Max);
|
|
|
|
|
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
2019-11-05 18:58:32 +08:00
|
|
|
|
EditorGUI.PropertyField(drawRect, m_TextStyle);
|
|
|
|
|
|
drawRect.y += EditorGUI.GetPropertyHeight(m_TextStyle);
|
2019-06-21 09:34:33 +08:00
|
|
|
|
|
2019-05-11 04:33:54 +08:00
|
|
|
|
--EditorGUI.indentLevel;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
|
|
|
|
|
{
|
2019-11-05 18:58:32 +08:00
|
|
|
|
if (ChartEditorHelper.IsToggle(m_RadarModuleToggle, prop))
|
2019-05-11 04:33:54 +08:00
|
|
|
|
{
|
2019-11-05 18:58:32 +08:00
|
|
|
|
var height = 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_TextStyle"));
|
|
|
|
|
|
return height;
|
2019-05-11 04:33:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|