From d90a0d69b20ed9035e73418e9f4042eee963b81b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 30 Dec 2022 22:13:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Editor`=E5=AF=B9`List`?= =?UTF-8?q?=E7=9A=84`+`=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=BE=91=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Editor/Utilities/ChartEditorHelper.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index ef1b27bb..7dfe3e2c 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -65,6 +65,7 @@ slug: /changelog ## master +* (2022.12.29) 增加`Editor`对`List`的`+`添加编辑功能 * (2022.12.29) 修复`UpdateXYData()`接口影响数据精度的问题 (#238) * (2022.12.28) 修复`Pie`只有一个数据时设置`border`后显示异常的问题 (#237) * (2022.12.22) 调整`Covert`重命名为`Convert`,涉及的接口有:`ConvertXYAxis()`,`CovertSerie()`等 diff --git a/Editor/Utilities/ChartEditorHelper.cs b/Editor/Utilities/ChartEditorHelper.cs index 859b5a9e..0c0aeb64 100644 --- a/Editor/Utilities/ChartEditorHelper.cs +++ b/Editor/Utilities/ChartEditorHelper.cs @@ -318,8 +318,8 @@ namespace XCharts.Editor { EditorGUI.indentLevel++; var listSize = listProp.arraySize; - var iconWidth = 14; - var iconGap = 3f; + var iconWidth = 10; + var iconGap = 0f; if (showSize) { @@ -383,20 +383,25 @@ namespace XCharts.Editor var isSerie = "Serie".Equals(element.type); var elementRect = isSerie ? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height) : - new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height); + new Rect(drawRect.x, drawRect.y, drawRect.width - 4 * iconWidth, drawRect.height); EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); - var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); + var iconRect = new Rect(drawRect.width - 4 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); var oldColor = GUI.contentColor; GUI.contentColor = Color.black; if (GUI.Button(iconRect, EditorCustomStyles.iconUp, EditorCustomStyles.invisibleButton)) { if (i > 0) listProp.MoveArrayElement(i, i - 1); } - iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); + iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); if (GUI.Button(iconRect, EditorCustomStyles.iconDown, EditorCustomStyles.invisibleButton)) { if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); } + iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); + if (GUI.Button(iconRect, EditorCustomStyles.iconAdd, EditorCustomStyles.invisibleButton)) + { + if (i < listProp.arraySize && i >= 0) listProp.InsertArrayElementAtIndex(i); + } iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height); if (GUI.Button(iconRect, EditorCustomStyles.iconRemove, EditorCustomStyles.invisibleButton)) {