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