[improve][editor] improve editor edit

This commit is contained in:
monitor1394
2022-08-10 08:16:19 +08:00
parent fcc1314f17
commit 65d32f7aec
4 changed files with 33 additions and 6 deletions

View File

@@ -68,6 +68,7 @@
### 日志详情 ### 日志详情
* (2022.08.10) 优化`Theme`的字体同步操作
* (2022.08.10) 优化`Chart`的默认`layer`设置为`UI` * (2022.08.10) 优化`Chart`的默认`layer`设置为`UI`
* (2022.08.09) 优化`Axis``Time`时间轴的次分割线 * (2022.08.09) 优化`Axis``Time`时间轴的次分割线
* (2022.08.09) 增加`AreaStyle``innerFill`参数支持填充凸多边形 * (2022.08.09) 增加`AreaStyle``innerFill`参数支持填充凸多边形

View File

@@ -12,8 +12,9 @@ namespace XCharts.Editor
{ {
static class Styles static class Styles
{ {
internal static GUIContent btnReset = new GUIContent("Reset", "Reset to default theme"); internal static GUIContent btnReset = new GUIContent("Reset to Default", "Reset to default theme");
internal static GUIContent btnSync = new GUIContent("Sync Font", "Sync main theme font to sub theme font"); 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; private Theme m_Theme;
@@ -28,11 +29,35 @@ namespace XCharts.Editor
base.OnInspectorGUI(); base.OnInspectorGUI();
if (GUILayout.Button(Styles.btnReset)) 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.");
}
} }
} }
} }

View File

@@ -156,7 +156,7 @@ namespace XCharts.Editor
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
var dataWidTotal = (currentWidth - (startX + 20.5f + 1)); var dataWidTotal = (currentWidth - (startX + 20.5f + 1));
var dataWid = dataWidTotal / fieldCount; var dataWid = dataWidTotal / fieldCount;
var xWid = dataWid - 2; var xWid = dataWid - 0;
for (int i = 0; i < dimension; i++) for (int i = 0; i < dimension; i++)
{ {
var dataCount = i < 1 ? 2 : i + 1; var dataCount = i < 1 ? 2 : i + 1;

View File

@@ -67,6 +67,7 @@ namespace XCharts.Editor
chart.transform.SetParent(parent); chart.transform.SetParent(parent);
chart.transform.localScale = Vector3.one; chart.transform.localScale = Vector3.one;
chart.transform.localPosition = Vector3.zero; chart.transform.localPosition = Vector3.zero;
chart.transform.localRotation = Quaternion.Euler(0, 0, 0);
var rect = chart.GetComponent<RectTransform>(); var rect = chart.GetComponent<RectTransform>();
rect.anchorMin = new Vector2(0.5f, 0.5f); rect.anchorMin = new Vector2(0.5f, 0.5f);
rect.anchorMax = new Vector2(0.5f, 0.5f); rect.anchorMax = new Vector2(0.5f, 0.5f);