private static void LoadLocalMetaFile() { try { CacheManager._programAssetMetaPath = LocalDirectoryHelper.GetProgramAssetMetaPath(); if (File.Exists(CacheManager._programAssetMetaPath)) { string text = File.ReadAllText(CacheManager._programAssetMetaPath); if (!string.IsNullOrEmpty(text)) { CacheManager._cachedProgramAssetInfoDict = (Json.Deserialize(text) as Dictionary <string, object>); } if (CacheManager._cachedProgramAssetInfoDict == null) { CacheManager._cachedProgramAssetInfoDict = new Dictionary <string, object>(); } } } catch (Exception ex) { string text2 = "CachedFile Meta文件读取失败 " + ex.Message; Logger.LogError(text2); Pandora.Instance.ReportError(text2, 10217587); } }
public static void Initialize() { LocalDirectoryHelper.CreateIfNotExists(); LocalDirectoryHelper.DeleteExpiredAsset(); LocalDirectoryHelper.DeleteExpiredCookie(); LocalDirectoryHelper.DeleteExpiredLog(); }
public static bool ParseImageAsset(string url, bool isCacheInMemory) { bool result = false; WWW www = AssetPool.GetWww(url); if (www != null) { try { Texture2D textureNonReadable = www.textureNonReadable; textureNonReadable.name = url; AssetPool.AddAsset(url, textureNonReadable, 0, isCacheInMemory); result = true; } catch (Exception ex) { string text = "资源解析失败: " + url + "\n" + ex.Message; Pandora.Instance.ReportError(text, 10217582); Logger.LogError(text); LocalDirectoryHelper.DeleteAssetByUrl(url); } AssetPool.DisposeWww(url); } return(result); }
public static bool ParseLuaAsset(string url) { bool result = false; WWW www = AssetPool.GetWww(url); if (www != null) { try { UnityEngine.Object[] array = www.assetBundle.LoadAll(typeof(TextAsset)); for (int i = 0; i < array.Length; i++) { UnityEngine.Object @object = array[i]; AssetPool.AddAsset(@object.name, @object, 999, true); } www.assetBundle.Unload(false); result = true; } catch (Exception ex) { string text = "资源解析失败 " + url + "\n" + ex.Message; Pandora.Instance.ReportError(text, 10217582); Logger.LogError(text); LocalDirectoryHelper.DeleteAssetByUrl(url); } AssetPool.DisposeWww(url); } return(result); }
public static void CreateIfNotExists() { Directory.CreateDirectory(LocalDirectoryHelper.GetProgramAssetFolderPath()); Directory.CreateDirectory(LocalDirectoryHelper.GetAssetFolderPath()); Directory.CreateDirectory(LocalDirectoryHelper.GetCookieFolderPath()); Directory.CreateDirectory(LocalDirectoryHelper.GetLogFolderPath()); Directory.CreateDirectory(LocalDirectoryHelper.GetSettingsFolderPath()); }
private static string GetAssetRealUrl(string url) { if (!PandoraSettings.UseStreamingAssets) { return(url); } string fileName = Path.GetFileName(url); if (!LocalDirectoryHelper.IsStreamingAssetsExists(fileName)) { return(url); } return(LocalDirectoryHelper.GetStreamingAssetsUrl() + "/" + fileName); }
public static string Read(string fileName) { try { string path = Path.Combine(LocalDirectoryHelper.GetCookieFolderPath(), fileName); if (File.Exists(path)) { return(File.ReadAllText(path)); } } catch (Exception ex) { string text = "读取Cookie失败, " + fileName + ex.Message; Pandora.Instance.ReportError(text, 0); Logger.LogError(text); } return(string.Empty); }
public static void ReadEnvironmentSetting() { try { string path = LocalDirectoryHelper.GetSettingsFolderPath() + "/settings.txt"; if (File.Exists(path)) { string json = File.ReadAllText(path); Dictionary <string, object> dictionary = Json.Deserialize(json) as Dictionary <string, object>; if (dictionary.ContainsKey("isProductEnvironment")) { PandoraSettings.IsProductEnvironment = (dictionary["isProductEnvironment"] as string == "1"); } } } catch { } }
private void ReadSettings() { try { string path = LocalDirectoryHelper.GetSettingsFolderPath() + "/settings.txt"; if (File.Exists(path)) { string json = File.ReadAllText(path); Dictionary <string, object> dictionary = Json.Deserialize(json) as Dictionary <string, object>; if (dictionary.ContainsKey("log")) { this._localLogSetting = (dictionary["log"] as string == "1"); } } } catch { } }
public void Init(bool isProductEnvironment, string rootName = "") { if (!this._isInitialized) { this._isInitialized = true; this._rootName = rootName; PandoraSettings.IsProductEnvironment = isProductEnvironment; PandoraSettings.ReadEnvironmentSetting(); this._userData = new UserData(); LocalDirectoryHelper.Initialize(); this.CreatePandoraGameObject(); this.AddLogHook(); CacheManager.Initialize(); AssetManager.Initialize(); PanelManager.Initialize(); TextPartner.GetFont = new Func <string, Font>(this.GetFont); Logger.LogLevel = PandoraSettings.DEFAULT_LOG_LEVEL; Logger.LogInfo("<color=#0000ff>Pandora Init " + this.GetSystemInfo() + "</color>"); } }
private void DrawLogSetting() { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Log选项:", new GUILayoutOption[0]); this._showDebug = GUILayout.Toggle(this._showInfo, "显示Debug", new GUILayoutOption[0]); this._showInfo = GUILayout.Toggle(this._showInfo, "显示Info", new GUILayoutOption[0]); this._showWarning = GUILayout.Toggle(this._showWarning, "显示警告", new GUILayoutOption[0]); this._showError = GUILayout.Toggle(this._showError, "显示错误", new GUILayoutOption[0]); if (GUILayout.Button("清空缓存", new GUILayoutOption[0])) { LocalDirectoryHelper.Clean(); } if (GUILayout.Button("清空所有Log", new GUILayoutOption[0])) { this._logList.Clear(); this._selectedLog = default(Log); } if (GUILayout.Button("关闭LogGUI", new GUILayoutOption[0])) { this._visible = false; } GUILayout.EndHorizontal(); }
public static bool Write(string fileName, string content) { try { string path = Path.Combine(LocalDirectoryHelper.GetCookieFolderPath(), fileName); File.WriteAllText(path, content); return(true); } catch (Exception ex) { string text = string.Concat(new string[] { "写入Cookie失败, ", fileName, " ", content, ex.Message }); Pandora.Instance.ReportError(text, 0); Logger.LogError(text); } return(false); }
public static bool ParsePrefabAsset(string url, bool isCacheInMemory) { bool result = false; WWW www = AssetPool.GetWww(url); if (www != null) { try { UnityEngine.Object[] array = new UnityEngine.Object[] { www.assetBundle.mainAsset }; if (array.Length > 1) { throw new Exception("资源打包不符合规范,一个AssetBundle中只能有一个Prefab, " + url); } for (int i = 0; i < array.Length; i++) { UnityEngine.Object obj = array[i]; AssetPool.AddAsset(url, obj, 0, isCacheInMemory); } www.assetBundle.Unload(false); result = true; } catch (Exception ex) { string text = "资源解析失败: " + url + "\n" + ex.Message; Pandora.Instance.ReportError(text, 10217582); Logger.LogError(text); LocalDirectoryHelper.DeleteAssetByUrl(url); } AssetPool.DisposeWww(url); } return(result); }
public static string GetCookieFolderPath() { return(Path.Combine(LocalDirectoryHelper.GetPandoraRoot(), "cookies")); }
private string GetLogFilePath() { return(LocalDirectoryHelper.GetLogFolderPath() + "/log-" + DateTime.Now.ToString("yyyy-MM-dd") + ".log"); }
public static string GetCachedAssetPath(string url) { string fileName = Path.GetFileName(url); return(Path.Combine(LocalDirectoryHelper.GetAssetFolderPath(), url.GetHashCode().ToString() + "-" + fileName)); }
public static string GetCachedProgramAssetPath(string url) { string fileName = Path.GetFileName(url); return(Path.Combine(LocalDirectoryHelper.GetProgramAssetFolderPath(), fileName)); }
public static void Clean() { LocalDirectoryHelper.DeleteDirectoryAssets(LocalDirectoryHelper.GetCookieFolderPath()); LocalDirectoryHelper.DeleteDirectoryAssets(LocalDirectoryHelper.GetLogFolderPath()); }
public static void DeleteExpiredLog() { LocalDirectoryHelper.DeleteExpiredAsset(LocalDirectoryHelper.GetLogFolderPath()); }
public static void DeleteExpiredCookie() { LocalDirectoryHelper.DeleteExpiredAsset(LocalDirectoryHelper.GetCookieFolderPath()); }
public static string GetAssetFolderPath() { return(Path.Combine(LocalDirectoryHelper.GetPandoraRoot(), "assets")); }
public static string GetProgramAssetMetaPath() { return(Path.Combine(LocalDirectoryHelper.GetProgramAssetFolderPath(), "meta.txt")); }
public static void DeleteCookies() { LocalDirectoryHelper.DeleteDirectoryAssets(LocalDirectoryHelper.GetCookieFolderPath()); }
public static string GetSettingsFolderPath() { return(Path.Combine(LocalDirectoryHelper.GetPandoraRoot(), "settings")); }