From f93355e6c4e801a0311483e08bd521a3424137a0 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 7 Jun 2020 18:22:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=BE=E4=BE=8B=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E8=B6=85=E8=8C=83=E5=9B=B4=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/PropertyDrawers/LocationDrawer.cs | 125 ++++++++++-------- .../Runtime/Internal/Helper/LegendHelper.cs | 24 ++-- 2 files changed, 79 insertions(+), 70 deletions(-) diff --git a/Assets/XCharts/Editor/PropertyDrawers/LocationDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/LocationDrawer.cs index 3f95f443..b8819f2a 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/LocationDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/LocationDrawer.cs @@ -25,69 +25,78 @@ namespace XCharts EditorGUI.PropertyField(drawRect, align, new GUIContent("Location")); drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; ++EditorGUI.indentLevel; - switch ((Location.Align)align.enumValueIndex) - { - case Location.Align.TopCenter: - EditorGUI.PropertyField(drawRect, top); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.TopLeft: - EditorGUI.PropertyField(drawRect, top); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, left); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.TopRight: - EditorGUI.PropertyField(drawRect, top); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, right); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.BottomCenter: - EditorGUI.PropertyField(drawRect, bottom); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.BottomLeft: - EditorGUI.PropertyField(drawRect, bottom); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, left); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.BottomRight: - EditorGUI.PropertyField(drawRect, bottom); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - EditorGUI.PropertyField(drawRect, right); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.Center: - break; - case Location.Align.CenterLeft: - EditorGUI.PropertyField(drawRect, left); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - case Location.Align.CenterRight: - EditorGUI.PropertyField(drawRect, right); - drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; - break; - } + EditorGUI.PropertyField(drawRect, top); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, bottom); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, left); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + EditorGUI.PropertyField(drawRect, right); + drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // switch ((Location.Align)align.enumValueIndex) + // { + // case Location.Align.TopCenter: + // EditorGUI.PropertyField(drawRect, top); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.TopLeft: + // EditorGUI.PropertyField(drawRect, top); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // EditorGUI.PropertyField(drawRect, left); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.TopRight: + // EditorGUI.PropertyField(drawRect, top); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // EditorGUI.PropertyField(drawRect, right); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.BottomCenter: + // EditorGUI.PropertyField(drawRect, bottom); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.BottomLeft: + // EditorGUI.PropertyField(drawRect, bottom); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // EditorGUI.PropertyField(drawRect, left); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.BottomRight: + // EditorGUI.PropertyField(drawRect, bottom); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // EditorGUI.PropertyField(drawRect, right); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.Center: + // break; + // case Location.Align.CenterLeft: + // EditorGUI.PropertyField(drawRect, left); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // case Location.Align.CenterRight: + // EditorGUI.PropertyField(drawRect, right); + // drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + // break; + // } --EditorGUI.indentLevel; } public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) { - SerializedProperty align = prop.FindPropertyRelative("m_Align"); - switch ((Location.Align)align.enumValueIndex) - { - case Location.Align.Center: - return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; - case Location.Align.TopCenter: - case Location.Align.BottomCenter: - case Location.Align.CenterLeft: - case Location.Align.CenterRight: - return 2 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; - default: - return 3 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; - } + return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing; + // SerializedProperty align = prop.FindPropertyRelative("m_Align"); + // switch ((Location.Align)align.enumValueIndex) + // { + // case Location.Align.Center: + // return 1 * EditorGUIUtility.singleLineHeight + 1 * EditorGUIUtility.standardVerticalSpacing; + // case Location.Align.TopCenter: + // case Location.Align.BottomCenter: + // case Location.Align.CenterLeft: + // case Location.Align.CenterRight: + // return 2 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing; + // default: + // return 3 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing; + // } } } } \ No newline at end of file diff --git a/Assets/XCharts/Runtime/Internal/Helper/LegendHelper.cs b/Assets/XCharts/Runtime/Internal/Helper/LegendHelper.cs index 88978548..f93eedf1 100644 --- a/Assets/XCharts/Runtime/Internal/Helper/LegendHelper.cs +++ b/Assets/XCharts/Runtime/Internal/Helper/LegendHelper.cs @@ -92,7 +92,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX += legendRuntimeWidth + legend.itemGap; @@ -105,7 +105,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX += legendRuntimeWidth + legend.itemGap; @@ -118,7 +118,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX -= legendRuntimeWidth + legend.itemGap; @@ -134,7 +134,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX += legendRuntimeWidth + legend.itemGap; @@ -148,7 +148,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX += legendRuntimeWidth + legend.itemGap; @@ -163,7 +163,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX -= legendRuntimeWidth + legend.itemGap; @@ -178,7 +178,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX += legendRuntimeWidth + legend.itemGap; @@ -193,7 +193,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX += legendRuntimeWidth + legend.itemGap; @@ -208,7 +208,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currHeight + item.height + legend.itemGap > legendHeight) + if (currHeight + item.height > legendHeight) { currHeight = 0; offsetX -= legendRuntimeWidth + legend.itemGap; @@ -229,7 +229,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currWidth + item.width + legend.itemGap >= legendWidth) + if (currWidth + item.width > legendWidth) { currWidth = 0f; if (isBottom) currHeight += legend.itemGap + item.height; @@ -247,7 +247,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currWidth + item.width + legend.itemGap >= legendWidth) + if (currWidth + item.width > legendWidth) { currWidth = 0f; if (isBottom) currHeight += legend.itemGap + item.height; @@ -265,7 +265,7 @@ namespace XCharts foreach (var kv in legend.buttonList) { var item = kv.Value; - if (currWidth + item.width + legend.itemGap >= legendWidth) + if (currWidth + item.width > legendWidth) { currWidth = 0f; if (isBottom) currHeight += legend.itemGap + item.height;