优化自定义主题Theme的自动刷新 (#148)

This commit is contained in:
monitor1394
2021-06-05 09:56:00 +08:00
parent 7b7150b87f
commit d6a024026b
4 changed files with 17 additions and 0 deletions

View File

@@ -35,6 +35,7 @@
## master
* (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
## v2.2.0

View File

@@ -35,6 +35,7 @@
## master
* (2021.06.04) 优化自定义主题`Theme`的自动刷新 (#148)
* (2021.06.04) 修复`Gauge`在最小值为负数时指针指示位置异常的问题
## v2.2.0

View File

@@ -1,3 +1,4 @@
using System.IO;
using UnityEditor;
using UnityEngine;
@@ -23,6 +24,12 @@ namespace XCharts
public static void CheckAddedAsset(string assetPath)
{
var fileName = Path.GetFileName(assetPath);
if (fileName.Equals("XChartsSettings.asset"))
{
XThemeMgr.ReloadThemeList();
return;
}
if (!IsThemeAsset(assetPath)) return;
var obj = AssetDatabase.LoadAssetAtPath<TextAsset>(assetPath);
if (obj == null || obj.text == null) return;

View File

@@ -94,6 +94,14 @@ 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);