mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
优化Theme
This commit is contained in:
@@ -25,6 +25,8 @@ namespace XCharts
|
||||
{
|
||||
if (!IsThemeAsset(assetPath)) return;
|
||||
var obj = AssetDatabase.LoadAssetAtPath<TextAsset>(assetPath);
|
||||
if (obj == null || obj.text == null) return;
|
||||
if (!obj.text.Contains("m_Theme")) return;
|
||||
if (XChartsSettings.AddJsonTheme(obj))
|
||||
{
|
||||
XThemeMgr.ReloadThemeList();
|
||||
@@ -54,6 +56,7 @@ namespace XCharts
|
||||
private static bool IsThemeAsset(string assetPath)
|
||||
{
|
||||
if (!assetPath.EndsWith(".json")) return false;
|
||||
if (!assetPath.StartsWith("XTheme")) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
AddTheme(ChartTheme.Dark);
|
||||
foreach (var json in XChartsSettings.customThemes)
|
||||
{
|
||||
if (json != null)
|
||||
if (json != null && !string.IsNullOrEmpty(json.text))
|
||||
{
|
||||
var theme = JsonUtility.FromJson<ChartTheme>(json.text);
|
||||
AddTheme(theme);
|
||||
@@ -36,6 +36,7 @@ namespace XCharts
|
||||
|
||||
public static void AddTheme(ChartTheme theme)
|
||||
{
|
||||
if (theme == null) return;
|
||||
if (!XChartsMgr.Instance.m_ThemeDict.ContainsKey(theme.themeName))
|
||||
{
|
||||
XChartsMgr.Instance.m_ThemeDict.Add(theme.themeName, theme);
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace XCharts
|
||||
|
||||
public static bool AddJsonTheme(TextAsset theme)
|
||||
{
|
||||
if (theme == null) return false;
|
||||
if (theme == null || string.IsNullOrEmpty(theme.text)) return false;
|
||||
if (!Instance.m_CustomThemes.Contains(theme))
|
||||
{
|
||||
Instance.m_CustomThemes.Add(theme);
|
||||
|
||||
Reference in New Issue
Block a user