优化主题Theme的导入和字体自动刷新 (#148)

This commit is contained in:
monitor1394
2021-06-12 14:32:23 +08:00
parent 442206dad8
commit f953a069cb
15 changed files with 272 additions and 69 deletions

View File

@@ -31,10 +31,6 @@ namespace XCharts
btnRect.y = m_DrawRect.y - EditorGUIUtility.singleLineHeight - 3;
btnRect.width = btnWidth;
var chart = prop.serializedObject.targetObject as BaseChart;
var lastFont = chart.theme.font;
#if dUI_TextMeshPro
var lastTMPFont = chart.theme.tmpFont;
#endif
if (GUI.Button(btnRect, new GUIContent("Reset", "Reset to theme default color")))
{
chart.theme.ResetTheme();
@@ -60,8 +56,18 @@ namespace XCharts
}
#if dUI_TextMeshPro
PropertyField(prop, "m_TMPFont");
if(chart.theme.tmpFont == null && !string.IsNullOrEmpty(chart.theme.tmpFontName))
{
var msg = string.Format("Can't find theme font asset:{0} in project.", chart.theme.tmpFontName);
EditorGUILayout.HelpBox(msg, MessageType.Error);
}
#else
PropertyField(prop, "m_Font");
if (chart.theme.font == null && !string.IsNullOrEmpty(chart.theme.fontName))
{
var msg = string.Format("Can't find theme font asset:{0} in project.", chart.theme.fontName);
EditorGUILayout.HelpBox(msg, MessageType.Error);
}
#endif
PropertyField(prop, "m_ContrastColor");
PropertyField(prop, "m_BackgroundColor");

View File

@@ -1,4 +1,11 @@
using UnityEngine;
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;

View File

@@ -1,3 +1,10 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.IO;
using UnityEditor;
using UnityEngine;
@@ -63,7 +70,8 @@ namespace XCharts
private static bool IsThemeAsset(string assetPath)
{
if (!assetPath.EndsWith(".json")) return false;
if (!assetPath.StartsWith("XTheme")) return false;
var assetName = Path.GetFileNameWithoutExtension(assetPath);
if (!assetName.StartsWith(XChartsSettings.THEME_ASSET_NAME_PREFIX)) return false;
return true;
}
}

View File

@@ -0,0 +1,28 @@
/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;
namespace XCharts
{
public class XChartsBuild : IPreprocessBuild, IPostprocessBuild
{
public int callbackOrder => 1;
public void OnPostprocessBuild(BuildTarget target, string path)
{
}
public void OnPreprocessBuild(BuildTarget target, string path)
{
XThemeMgr.ExportAllCustomTheme();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df212e63c528e40fa9e8fffcd868ab7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: