From f953a069cb0481fbbc869e6d078d5a73c5fd80fa Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 12 Jun 2021 14:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BB=E9=A2=98`Theme`?= =?UTF-8?q?=E7=9A=84=E5=AF=BC=E5=85=A5=E5=92=8C=E5=AD=97=E4=BD=93=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=B7=E6=96=B0=20(#148)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/XCharts/CHANGELOG-EN.md | 3 +- Assets/XCharts/CHANGELOG.md | 3 +- .../Editor/PropertyDrawers/ThemeDrawer.cs | 14 +- .../Editor/Utility/ChartEditorHelper.cs | 9 +- Assets/XCharts/Editor/Utility/ThemeCheck.cs | 10 +- Assets/XCharts/Editor/Utility/XChartsBuild.cs | 28 ++++ .../Editor/Utility/XChartsBuild.cs.meta | 11 ++ Assets/XCharts/Runtime/API/BaseChart_API.cs | 1 + .../Runtime/Component/Theme/ChartTheme.cs | 73 ++++++++- .../Runtime/Component/Theme/ComponentTheme.cs | 6 +- Assets/XCharts/Runtime/Internal/BaseChart.cs | 4 - .../Runtime/Internal/Object/ChartText.cs | 4 - Assets/XCharts/Runtime/Mgr/XThemeMgr.cs | 145 ++++++++++++++---- Assets/XCharts/Runtime/XChartsMgr.cs | 19 +-- Assets/XCharts/Runtime/XChartsSettings.cs | 11 +- 15 files changed, 272 insertions(+), 69 deletions(-) create mode 100644 Assets/XCharts/Editor/Utility/XChartsBuild.cs create mode 100644 Assets/XCharts/Editor/Utility/XChartsBuild.cs.meta diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index 56ee5fcc..c321c61d 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -35,10 +35,11 @@ ## master +* (2021.06.12) Optimized import of `Theme` and automatic font refresh (#148) * (2021.06.10) Fixed compatibility issues with `Unity` version (#154) * (2021.06.05) Improved Candlestickchart support for inverse (#152) * (2021.06.04) Optimized auto-refresh of custom `Theme` (#148) -* (2021.06.04) Fixed `Gauge` having an abnormal pointer position when the minimum value is negative +* (2021.06.04) Fixed `Gauge` having an abnormal pointer position when the minimum value is negative (#153) ## v2.2.0 diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index d0c9bd6f..fee7dac4 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -35,10 +35,11 @@ ## master +* (2021.06.12) 优化主题`Theme`的导入和字体自动刷新 (#148) * (2021.06.10) 修复`Unity`版本兼容问题 (#154) * (2021.06.05) 完善`CandlestickChart`对`inverse`的支持 (#152) * (2021.06.04) 优化自定义主题`Theme`的自动刷新 (#148) -* (2021.06.04) 修复`Gauge`在最小值为负数时指针指示位置异常的问题 +* (2021.06.04) 修复`Gauge`在最小值为负数时指针指示位置异常的问题 (#153) ## v2.2.0 diff --git a/Assets/XCharts/Editor/PropertyDrawers/ThemeDrawer.cs b/Assets/XCharts/Editor/PropertyDrawers/ThemeDrawer.cs index d7c5842b..6d2d5fef 100644 --- a/Assets/XCharts/Editor/PropertyDrawers/ThemeDrawer.cs +++ b/Assets/XCharts/Editor/PropertyDrawers/ThemeDrawer.cs @@ -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"); diff --git a/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs b/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs index b11f54e5..6534695a 100644 --- a/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs +++ b/Assets/XCharts/Editor/Utility/ChartEditorHelper.cs @@ -1,4 +1,11 @@ -using UnityEngine; +/************************************************/ +/* */ +/* Copyright (c) 2018 - 2021 monitor1394 */ +/* https://github.com/monitor1394 */ +/* */ +/************************************************/ + +using UnityEngine; using UnityEditor; using System.Collections.Generic; diff --git a/Assets/XCharts/Editor/Utility/ThemeCheck.cs b/Assets/XCharts/Editor/Utility/ThemeCheck.cs index f2a49510..cc3070fd 100644 --- a/Assets/XCharts/Editor/Utility/ThemeCheck.cs +++ b/Assets/XCharts/Editor/Utility/ThemeCheck.cs @@ -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; } } diff --git a/Assets/XCharts/Editor/Utility/XChartsBuild.cs b/Assets/XCharts/Editor/Utility/XChartsBuild.cs new file mode 100644 index 00000000..9c8f2f28 --- /dev/null +++ b/Assets/XCharts/Editor/Utility/XChartsBuild.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/Assets/XCharts/Editor/Utility/XChartsBuild.cs.meta b/Assets/XCharts/Editor/Utility/XChartsBuild.cs.meta new file mode 100644 index 00000000..b202a37f --- /dev/null +++ b/Assets/XCharts/Editor/Utility/XChartsBuild.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: df212e63c528e40fa9e8fffcd868ab7d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/XCharts/Runtime/API/BaseChart_API.cs b/Assets/XCharts/Runtime/API/BaseChart_API.cs index 471e9ca3..d2820f39 100644 --- a/Assets/XCharts/Runtime/API/BaseChart_API.cs +++ b/Assets/XCharts/Runtime/API/BaseChart_API.cs @@ -637,6 +637,7 @@ namespace XCharts public void UpdateTheme(ChartTheme theme) { m_Theme.CopyTheme(theme); + SetAllComponentDirty(); } /// diff --git a/Assets/XCharts/Runtime/Component/Theme/ChartTheme.cs b/Assets/XCharts/Runtime/Component/Theme/ChartTheme.cs index 5c32bd1f..809451d9 100644 --- a/Assets/XCharts/Runtime/Component/Theme/ChartTheme.cs +++ b/Assets/XCharts/Runtime/Component/Theme/ChartTheme.cs @@ -47,6 +47,10 @@ namespace XCharts { [SerializeField] private Theme m_Theme = Theme.Default; [SerializeField] private string m_ThemeName = Theme.Default.ToString(); + [SerializeField] private string m_FontName; + [SerializeField] private string m_TMPFontName; + [SerializeField] private int m_FontInstacneId; + [SerializeField] private int m_TMPFontInstanceId; [SerializeField] private Font m_Font; #if dUI_TextMeshPro [SerializeField] private TMP_FontAsset m_TMPFont; @@ -75,6 +79,12 @@ namespace XCharts [SerializeField] private VisualMapTheme m_VisualMap; [SerializeField] private SerieTheme m_Serie; + private ChartTheme() + { + m_FontName = "Arial"; + m_TMPFontName = "LiberationSans SDF"; + } + /// /// the theme of chart. /// 主题类型。 @@ -110,6 +120,27 @@ namespace XCharts set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); } } + public string fontName + { + get { return m_FontName; } + set { if (PropertyUtil.SetClass(ref m_FontName, value)) SetComponentDirty(); } + } + public int fontInstanceId + { + get { return m_FontInstacneId; } + set { if (PropertyUtil.SetStruct(ref m_FontInstacneId, value)) SetComponentDirty(); } + } + public string tmpFontName + { + get { return m_TMPFontName; } + set { if (PropertyUtil.SetClass(ref m_TMPFontName, value)) SetComponentDirty(); } + } + public int tmpFontInstanceId + { + get { return m_TMPFontInstanceId; } + set { if (PropertyUtil.SetStruct(ref m_TMPFontInstanceId, value)) SetComponentDirty(); } + } + /// /// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series. /// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。 @@ -139,11 +170,14 @@ namespace XCharts get { return m_TMPFont; } set { - if (PropertyUtil.SetClass(ref m_TMPFont, value)) + m_TMPFont = value; + if(value) { - SetComponentDirty(); - SyncTMPFontToSubComponent(); + m_TMPFontName = value.name; + m_TMPFontInstanceId = value.GetInstanceID(); } + SetComponentDirty(); + SyncTMPFontToSubComponent(); } } #endif @@ -156,11 +190,14 @@ namespace XCharts get { return m_Font; } set { - if (PropertyUtil.SetClass(ref m_Font, value)) + m_Font = value; + if (value) { - SetComponentDirty(); - SyncFontToSubComponent(); + m_FontName = value.name; + m_FontInstacneId = value.GetInstanceID(); } + SetComponentDirty(); + SyncFontToSubComponent(); } } @@ -262,9 +299,13 @@ namespace XCharts m_Theme = theme.theme; m_ThemeName = theme.themeName; #if dUI_TextMeshPro - m_TMPFont = theme.tmpFont; + tmpFont = theme.tmpFont; #endif - m_Font = theme.m_Font; + font = theme.font; + m_FontName = theme.fontName; + m_FontInstacneId = theme.fontInstanceId; + m_TMPFontName = theme.tmpFontName; + m_TMPFontInstanceId = theme.tmpFontInstanceId; m_ContrastColor = theme.contrastColor; m_BackgroundColor = theme.m_BackgroundColor; m_Common.Copy(theme.common); @@ -438,6 +479,22 @@ namespace XCharts } } + public void SyncFontName() + { + if (font) + { + m_FontName = font.name; + m_FontInstacneId = font.GetInstanceID(); + } +#if dUI_TextMeshPro + if (tmpFont) + { + m_TMPFontName = tmpFont.name; + m_TMPFontInstanceId = tmpFont.GetInstanceID(); + } +#endif + } + public void SyncFontToSubComponent() { common.font = font; diff --git a/Assets/XCharts/Runtime/Component/Theme/ComponentTheme.cs b/Assets/XCharts/Runtime/Component/Theme/ComponentTheme.cs index 43059732..80839ee7 100644 --- a/Assets/XCharts/Runtime/Component/Theme/ComponentTheme.cs +++ b/Assets/XCharts/Runtime/Component/Theme/ComponentTheme.cs @@ -25,13 +25,13 @@ namespace XCharts #endif /// - /// the font of text。 + /// the font of text. /// 字体。 /// public Font font { get { return m_Font; } - set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); } + set { m_Font = value; SetComponentDirty(); } } /// /// the color of text. @@ -69,7 +69,7 @@ namespace XCharts public TMP_FontAsset tmpFont { get { return m_TMPFont; } - set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); } + set { m_TMPFont = value; SetComponentDirty(); } } #endif diff --git a/Assets/XCharts/Runtime/Internal/BaseChart.cs b/Assets/XCharts/Runtime/Internal/BaseChart.cs index f441b963..87995420 100644 --- a/Assets/XCharts/Runtime/Internal/BaseChart.cs +++ b/Assets/XCharts/Runtime/Internal/BaseChart.cs @@ -216,10 +216,6 @@ namespace XCharts } else { - if (m_Theme.font == null) - { - m_Theme.font = XChartsSettings.font; - } if (m_Theme.colorPalette.Count == 0) { m_Theme.ResetTheme(); diff --git a/Assets/XCharts/Runtime/Internal/Object/ChartText.cs b/Assets/XCharts/Runtime/Internal/Object/ChartText.cs index 0b2cecc2..007ce74d 100644 --- a/Assets/XCharts/Runtime/Internal/Object/ChartText.cs +++ b/Assets/XCharts/Runtime/Internal/Object/ChartText.cs @@ -241,10 +241,6 @@ namespace XCharts } #if dUI_TextMeshPro - public void SetAlignment(TextAlignmentOptions alignment) - { - if (m_TMPText != null) m_TMPText.alignment = alignment; - } public void SetFont(TMP_FontAsset font) { diff --git a/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs b/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs index 61b286ec..e1f8b40f 100644 --- a/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs +++ b/Assets/XCharts/Runtime/Mgr/XThemeMgr.cs @@ -3,21 +3,23 @@ using System.Collections.Generic; using System.IO; using UnityEngine; +using System.Reflection; #if UNITY_EDITOR using UnityEditor; #endif +#if dUI_TextMeshPro +using TMPro; +#endif namespace XCharts { public static class XThemeMgr { - /// /// 重新加载主题列表 /// public static void ReloadThemeList() { - //Debug.Log("LoadThemesFromResources"); XChartsMgr.Instance.m_ThemeDict.Clear(); XChartsMgr.Instance.m_ThemeNames.Clear(); AddTheme(ChartTheme.Default); @@ -28,10 +30,69 @@ namespace XCharts if (json != null && !string.IsNullOrEmpty(json.text)) { var theme = JsonUtility.FromJson(json.text); + theme.font = GetCustomThemeFont(theme); +#if dUI_TextMeshPro + theme.tmpFont = GetCustomThemeTMPFont(theme); +#endif AddTheme(theme); } } - //Debug.Log("LoadThemesFromResources DONE: theme count=" + m_ThemeDict.Keys.Count); + } + + private static Font GetCustomThemeFont(ChartTheme theme) + { + Font font = null; +#if UNITY_EDITOR + if (string.IsNullOrEmpty(theme.fontName)) return null; + if (theme.fontName.Equals("Arial")) return Resources.GetBuiltinResource("Arial.ttf"); + var guids = AssetDatabase.FindAssets("t:Font"); + foreach (var guid in guids) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + var tempFont = AssetDatabase.LoadAssetAtPath(assetPath); + if (tempFont.name.Equals(theme.fontName)) + { + font = tempFont; + break; + } + } +#else + font = FindObjectByInstanceId(theme.fontInstanceId) as Font; +#endif + return font; + } + +#if dUI_TextMeshPro + private static TMP_FontAsset GetCustomThemeTMPFont(ChartTheme theme) + { + TMP_FontAsset font = null; +#if UNITY_EDITOR + if (!string.IsNullOrEmpty(theme.tmpFontName)){ + //TODO: how to find TMP_FontAsset asset + var guids = AssetDatabase.FindAssets("t:Texture"); + foreach (var guid in guids) + { + var assetPath = AssetDatabase.GUIDToAssetPath(guid); + if(!assetPath.EndsWith(".asset"))continue; + var tempFont = AssetDatabase.LoadAssetAtPath(assetPath); + if (tempFont && tempFont.name.Equals(theme.tmpFontName)) + { + font = tempFont; + break; + } + } + } +#else + font = FindObjectByInstanceId(theme.fontInstanceId) as TMP_FontAsset; +#endif + return font; + } +#endif + + public static Object FindObjectByInstanceId(int instanceId) + { + return (Object)typeof(Object).GetMethod("FindObjectFromInstanceID", + BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, new object[] { instanceId }); } public static void AddTheme(ChartTheme theme) @@ -42,10 +103,6 @@ namespace XCharts XChartsMgr.Instance.m_ThemeDict.Add(theme.themeName, theme); XChartsMgr.Instance.m_ThemeNames.Add(theme.themeName); } - else - { - Debug.LogError("Theme name is exist:" + theme.themeName); - } } public static ChartTheme GetTheme(string themeName) @@ -62,6 +119,16 @@ namespace XCharts return XChartsMgr.Instance.m_ThemeNames; } + public static List GetThemeList() + { + var list = new List(); + foreach (var theme in XChartsMgr.Instance.m_ThemeDict.Values) + { + list.Add(theme); + } + return list; + } + public static bool ContainsTheme(string themeName) { return XChartsMgr.Instance.m_ThemeNames.Contains(themeName); @@ -69,7 +136,6 @@ namespace XCharts public static void SwitchTheme(BaseChart chart, string themeName) { - Debug.Log("SwitchTheme:" + themeName); #if UNITY_EDITOR if (XChartsMgr.Instance.m_ThemeDict.Count == 0) { @@ -82,8 +148,7 @@ namespace XCharts return; } var target = XChartsMgr.Instance.m_ThemeDict[themeName]; - chart.theme.CopyTheme(target); - chart.RefreshAllComponent(); + chart.UpdateTheme(target); } public static bool ExportTheme(ChartTheme theme, string themeNewName) @@ -94,22 +159,9 @@ namespace XCharts newtheme.theme = Theme.Custom; newtheme.themeName = themeNewName; - if (!Directory.Exists(Application.dataPath + "/XCharts")) - { - Directory.CreateDirectory(Application.dataPath + "/XCharts"); - } - if (!Directory.Exists(Application.dataPath + "/XCharts/Resources")) - { - Directory.CreateDirectory(Application.dataPath + "/XCharts/Resources"); - } - var themeFileName = "XTheme-" + newtheme.themeName; - var assetPath = string.Format("Assets/XCharts/Resources/{0}", themeFileName); - var filePath = string.Format("{0}/../{1}.json", Application.dataPath, assetPath); - var json = JsonUtility.ToJson(newtheme, true); - File.WriteAllText(filePath, json); - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - var obj = Resources.Load(themeFileName); + ExportTheme(newtheme); + var themeAssetName = XChartsSettings.THEME_ASSET_NAME_PREFIX + theme.themeName; + var obj = Resources.Load(themeAssetName); XChartsSettings.AddJsonTheme(obj); ReloadThemeList(); return true; @@ -118,9 +170,48 @@ namespace XCharts #endif } + public static bool ExportTheme(ChartTheme theme) + { +#if UNITY_EDITOR + theme.SyncFontName(); + var themeAssetName = XChartsSettings.THEME_ASSET_NAME_PREFIX + theme.themeName; + var themeAssetPath = Application.dataPath + "/../" + XChartsSettings.THEME_ASSET_FOLDER; + if (!Directory.Exists(themeAssetPath)) + { + Directory.CreateDirectory(themeAssetPath); + } + var assetPath = string.Format("{0}/{1}", XChartsSettings.THEME_ASSET_FOLDER, themeAssetName); + var themeAssetFilePath = string.Format("{0}/{1}.json", themeAssetPath, themeAssetName); + var json = JsonUtility.ToJson(theme, true); + File.WriteAllText(themeAssetFilePath, json); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + return true; +#else + return false; +#endif + } + + public static void ExportAllCustomTheme() + { + var list = new List(); + foreach (var theme in XChartsMgr.Instance.m_ThemeDict.Values) + { + if (theme.theme == Theme.Custom) + { + list.Add(theme); + } + } + foreach (var theme in list) + { + ExportTheme(theme); + } + } + public static string GetThemeAssetPath(string themeName) { - return string.Format("Assets/XCharts/Resources/XTheme-{0}.json", themeName); + return string.Format("{0}/{1}{2}.json", XChartsSettings.THEME_ASSET_FOLDER, + XChartsSettings.THEME_ASSET_NAME_PREFIX, themeName); } } } \ No newline at end of file diff --git a/Assets/XCharts/Runtime/XChartsMgr.cs b/Assets/XCharts/Runtime/XChartsMgr.cs index fc8a9ce7..942fd3c7 100644 --- a/Assets/XCharts/Runtime/XChartsMgr.cs +++ b/Assets/XCharts/Runtime/XChartsMgr.cs @@ -30,9 +30,6 @@ namespace XCharts public string homepage = ""; } -#if UNITY_EDITOR - [InitializeOnLoad] -#endif [ExecuteInEditMode] public class XChartsMgr : MonoBehaviour { @@ -67,19 +64,13 @@ namespace XCharts } } - private XChartsMgr() - { - } - - static XChartsMgr() - { #if UNITY_EDITOR - EditorApplication.delayCall += () => - { - var mgr = XChartsMgr.Instance; - }; -#endif + [InitializeOnLoadMethod] + private static void OnInitializeOnLoadMethod() + { + XThemeMgr.ReloadThemeList(); } +#endif private void Awake() { diff --git a/Assets/XCharts/Runtime/XChartsSettings.cs b/Assets/XCharts/Runtime/XChartsSettings.cs index d2b09b70..425b54b6 100644 --- a/Assets/XCharts/Runtime/XChartsSettings.cs +++ b/Assets/XCharts/Runtime/XChartsSettings.cs @@ -11,6 +11,9 @@ using System.Collections.Generic; #if dUI_TextMeshPro using TMPro; #endif +#if UNITY_EDITOR +using UnityEditor; +#endif namespace XCharts { @@ -21,6 +24,8 @@ namespace XCharts #endif public class XChartsSettings : ScriptableObject { + public readonly static string THEME_ASSET_NAME_PREFIX = "XTheme-"; + public readonly static string THEME_ASSET_FOLDER = "Assets/XCharts/Resources"; [SerializeField] private Font m_Font = null; #if dUI_TextMeshPro @@ -145,7 +150,6 @@ namespace XCharts } #endif } - return s_Instance; } } @@ -156,6 +160,11 @@ namespace XCharts if (!Instance.m_CustomThemes.Contains(theme)) { Instance.m_CustomThemes.Add(theme); +#if UNITY_EDITOR + EditorUtility.SetDirty(Instance); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); +#endif return true; } return false;