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)) {