From 65d32f7aec0914bfaa0e0ef74738ec847f26fd76 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 10 Aug 2022 08:16:19 +0800 Subject: [PATCH] [improve][editor] improve editor edit --- CHANGELOG.md | 1 + Editor/MainComponents/ThemeEditor.cs | 35 ++++++++++++++++++++++++---- Editor/Series/SerieEditor.cs | 2 +- Editor/Windows/XChartsEditor.cs | 1 + 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 879a8495..b6783212 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ ### 日志详情 +* (2022.08.10) 优化`Theme`的字体同步操作 * (2022.08.10) 优化`Chart`的默认`layer`设置为`UI` * (2022.08.09) 优化`Axis`的`Time`时间轴的次分割线 * (2022.08.09) 增加`AreaStyle`的`innerFill`参数支持填充凸多边形 diff --git a/Editor/MainComponents/ThemeEditor.cs b/Editor/MainComponents/ThemeEditor.cs index 86fcf5f7..76012efe 100644 --- a/Editor/MainComponents/ThemeEditor.cs +++ b/Editor/MainComponents/ThemeEditor.cs @@ -12,8 +12,9 @@ namespace XCharts.Editor { static class Styles { - internal static GUIContent btnReset = new GUIContent("Reset", "Reset to default theme"); - internal static GUIContent btnSync = new GUIContent("Sync Font", "Sync main theme font to sub theme font"); + internal static GUIContent btnReset = new GUIContent("Reset to Default", "Reset to default theme"); + internal static GUIContent btnSyncFontToSubTheme = new GUIContent("Sync Font to Sub Theme", "Sync main theme font to sub theme font"); + internal static GUIContent btnSyncFontFromSetting = new GUIContent("Sync Font from Setting", "Sync main theme font and sub theme font from XCSetting font"); } private Theme m_Theme; @@ -28,11 +29,35 @@ namespace XCharts.Editor base.OnInspectorGUI(); if (GUILayout.Button(Styles.btnReset)) { - m_Theme.ResetTheme(); + if (EditorUtility.DisplayDialog(Styles.btnReset.text, Styles.btnReset.tooltip, "Yes", "Cancel")) + { + m_Theme.ResetTheme(); + Debug.Log("XCharts: Reset Finish."); + } } - if (GUILayout.Button(Styles.btnSync)) + if (GUILayout.Button(Styles.btnSyncFontFromSetting)) { - m_Theme.SyncFontToSubComponent(); + if (EditorUtility.DisplayDialog(Styles.btnSyncFontFromSetting.text, Styles.btnSyncFontFromSetting.tooltip, "Yes", "Cancel")) + { + m_Theme.common.font = XCSettings.font; + m_Theme.SyncFontToSubComponent(); +#if dUI_TextMeshPro + m_Theme.common.tmpFont = XCSettings.tmpFont; + m_Theme.SyncTMPFontToSubComponent(); +#endif + Debug.Log("XCharts: Sync Finish."); + } + } + if (GUILayout.Button(Styles.btnSyncFontToSubTheme)) + { + if (EditorUtility.DisplayDialog(Styles.btnSyncFontToSubTheme.text, Styles.btnSyncFontToSubTheme.tooltip, "Yes", "Cancel")) + { + m_Theme.SyncFontToSubComponent(); +#if dUI_TextMeshPro + m_Theme.SyncTMPFontToSubComponent(); +#endif + Debug.Log("XCharts: Sync Finish."); + } } } } diff --git a/Editor/Series/SerieEditor.cs b/Editor/Series/SerieEditor.cs index 33f62f68..82cfa37d 100644 --- a/Editor/Series/SerieEditor.cs +++ b/Editor/Series/SerieEditor.cs @@ -156,7 +156,7 @@ namespace XCharts.Editor var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; var dataWidTotal = (currentWidth - (startX + 20.5f + 1)); var dataWid = dataWidTotal / fieldCount; - var xWid = dataWid - 2; + var xWid = dataWid - 0; for (int i = 0; i < dimension; i++) { var dataCount = i < 1 ? 2 : i + 1; diff --git a/Editor/Windows/XChartsEditor.cs b/Editor/Windows/XChartsEditor.cs index 6725ae7b..ed33ec98 100644 --- a/Editor/Windows/XChartsEditor.cs +++ b/Editor/Windows/XChartsEditor.cs @@ -67,6 +67,7 @@ namespace XCharts.Editor chart.transform.SetParent(parent); chart.transform.localScale = Vector3.one; chart.transform.localPosition = Vector3.zero; + chart.transform.localRotation = Quaternion.Euler(0, 0, 0); var rect = chart.GetComponent(); rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f);