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; } if (!obj.text.Contains("m_Theme")) { return; } if (XChartsSettings.AddJsonTheme(obj)) { XThemeMgr.ReloadThemeList(); } }
public static bool ExportTheme(ChartTheme theme, string themeNewName) { #if UNITY_EDITOR var newtheme = ChartTheme.EmptyTheme; newtheme.CopyTheme(theme); newtheme.theme = Theme.Custom; newtheme.themeName = themeNewName; ExportTheme(newtheme); var themeAssetName = XChartsSettings.THEME_ASSET_NAME_PREFIX + theme.themeName; var obj = Resources.Load <TextAsset>(themeAssetName); XChartsSettings.AddJsonTheme(obj); ReloadThemeList(); return(true); #else return(false); #endif }
public static bool ExportTheme(ChartTheme theme, string themeNewName) { #if UNITY_EDITOR var newtheme = ChartTheme.EmptyTheme; newtheme.CopyTheme(theme); newtheme.theme = Theme.Custom; newtheme.themeName = themeNewName; 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 <TextAsset>(themeFileName); XChartsSettings.AddJsonTheme(obj); ReloadThemeList(); return(true); #else return(false); #endif }