VisualMap支持Piecewise类型

This commit is contained in:
monitor1394
2021-05-10 12:45:58 +08:00
parent dc1040ab02
commit 1f77461d05
8 changed files with 165 additions and 81 deletions

View File

@@ -21,14 +21,22 @@ namespace XCharts
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_Direction");
PropertyField(prop, "m_AutoMinMax");
PropertyField(prop, "m_Min");
PropertyField(prop, "m_Max");
PropertyField(prop, "m_SplitNumber");
PropertyField(prop, "m_Dimension");
PropertyListField(prop, "m_InRange");
PropertyListField(prop, "m_OutOfRange");
var type = (VisualMap.Type)prop.FindPropertyRelative("m_Type").enumValueIndex;
switch (type)
{
case VisualMap.Type.Continuous:
PropertyListField(prop, "m_InRange");
break;
case VisualMap.Type.Piecewise:
PropertyListField(prop, "m_Pieces");
break;
}
PropertyField(prop, "m_Show");
if (prop.FindPropertyRelative("m_Show").boolValue)
{
@@ -48,4 +56,23 @@ namespace XCharts
}
}
}
[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;
}
}
}
}