Files
XCharts/Editor/PropertyDrawers/VisualMapDrawer.cs

72 lines
2.9 KiB
C#
Raw Normal View History

2021-01-11 08:54:28 +08:00
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEditor;
2019-10-14 07:45:56 +08:00
using UnityEngine;
namespace XCharts
{
[CustomPropertyDrawer(typeof(VisualMap), true)]
2021-01-11 08:54:28 +08:00
public class VisualMapDrawer : BasePropertyDrawer
2019-10-14 07:45:56 +08:00
{
2021-01-11 08:54:28 +08:00
public override string ClassName { get { return "VisualMap"; } }
2019-10-14 07:45:56 +08:00
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
2021-01-11 08:54:28 +08:00
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, "m_Enable"))
2019-10-14 07:45:56 +08:00
{
++EditorGUI.indentLevel;
2021-05-13 09:38:32 +08:00
var type = (VisualMap.Type)prop.FindPropertyRelative("m_Type").enumValueIndex;
var isPiece = type == VisualMap.Type.Piecewise;
2021-01-11 08:54:28 +08:00
PropertyField(prop, "m_Type");
PropertyField(prop, "m_AutoMinMax");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_SplitNumber");
PropertyField(prop, "m_Dimension");
2021-01-17 22:52:32 +08:00
PropertyListField(prop, "m_OutOfRange");
2021-05-13 09:38:32 +08:00
PropertyListField(prop, isPiece ? "m_Pieces" : "m_InRange");
2021-01-11 08:54:28 +08:00
PropertyField(prop, "m_Show");
2019-10-14 07:45:56 +08:00
if (prop.FindPropertyRelative("m_Show").boolValue)
{
2021-01-11 08:54:28 +08:00
PropertyField(prop, "m_SelectedMode");
PropertyTwoFiled(prop, "m_Range");
PropertyTwoFiled(prop, "m_Text");
PropertyTwoFiled(prop, "m_TextGap");
PropertyField(prop, "m_HoverLink");
PropertyField(prop, "m_Calculable");
PropertyField(prop, "m_ItemWidth");
PropertyField(prop, "m_ItemHeight");
2021-05-13 09:38:32 +08:00
if (isPiece) PropertyField(prop, "m_ItemGap");
2021-01-11 08:54:28 +08:00
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_Orient");
PropertyField(prop, "m_Location");
2019-10-14 07:45:56 +08:00
}
2021-01-11 08:54:28 +08:00
--EditorGUI.indentLevel;
2019-10-14 07:45:56 +08:00
}
}
}
2021-05-10 12:45:58 +08:00
[CustomPropertyDrawer(typeof(VisualMap.Pieces), true)]
public class PiecesDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Pieces"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeFoldout(prop, ""))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_Label");
PropertyField(prop, "m_Color");
--EditorGUI.indentLevel;
}
}
}
2019-10-14 07:45:56 +08:00
}