mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
增加SplitArea配置坐标轴分割区域
This commit is contained in:
@@ -48,6 +48,7 @@ namespace XCharts
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Data");
|
||||
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
||||
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
||||
@@ -110,6 +111,9 @@ namespace XCharts
|
||||
EditorGUI.PropertyField(drawRect, m_AxisTick);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||
EditorGUI.PropertyField(drawRect, m_SplitArea);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_SplitArea);
|
||||
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
@@ -137,8 +141,9 @@ namespace XCharts
|
||||
SerializedProperty m_Type = prop.FindPropertyRelative("m_Type");
|
||||
SerializedProperty m_AxisTick = prop.FindPropertyRelative("m_AxisTick");
|
||||
SerializedProperty m_AxisName = prop.FindPropertyRelative("m_AxisName");
|
||||
SerializedProperty m_SplitArea = prop.FindPropertyRelative("m_SplitArea");
|
||||
float height = 0;
|
||||
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 9 * EditorGUIUtility.singleLineHeight + 8 * EditorGUIUtility.standardVerticalSpacing;
|
||||
Axis.AxisType type = (Axis.AxisType)m_Type.enumValueIndex;
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
@@ -170,6 +175,7 @@ namespace XCharts
|
||||
}
|
||||
height += EditorGUI.GetPropertyHeight(m_AxisName);
|
||||
height += EditorGUI.GetPropertyHeight(m_AxisTick);
|
||||
height += EditorGUI.GetPropertyHeight(m_SplitArea);
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
54
Scripts/Editor/PropertyDrawers/AxisSplitAreaDrawer.cs
Normal file
54
Scripts/Editor/PropertyDrawers/AxisSplitAreaDrawer.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(Axis.SplitArea), true)]
|
||||
public class AxisSplitAreaDrawer : PropertyDrawer
|
||||
{
|
||||
private bool m_ColorFoldout = false;
|
||||
private int m_ColorSize = 0;
|
||||
private bool m_SplitAreaToggle = 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_Color = prop.FindPropertyRelative("m_Color");
|
||||
|
||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_SplitAreaToggle, "Split Area", show, false);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_SplitAreaToggle)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
m_ColorFoldout = EditorGUI.Foldout(drawRect, m_ColorFoldout, "Color");
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
drawRect.width = pos.width;
|
||||
if (m_ColorFoldout)
|
||||
{
|
||||
ChartEditorHelper.MakeList(ref drawRect, ref m_ColorSize, m_Color);
|
||||
}
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
float height = 0;
|
||||
if (m_SplitAreaToggle)
|
||||
{
|
||||
height += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
if (m_ColorFoldout)
|
||||
{
|
||||
SerializedProperty m_Data = prop.FindPropertyRelative("m_Color");
|
||||
int num = m_Data.arraySize + 1;
|
||||
height += num * EditorGUIUtility.singleLineHeight + (num - 1) * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
}
|
||||
return height;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Scripts/Editor/PropertyDrawers/AxisSplitAreaDrawer.cs.meta
Normal file
11
Scripts/Editor/PropertyDrawers/AxisSplitAreaDrawer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 988570bd6485942da9879649ed4adb5b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user