public static String LoadText(String fileName) { try { if (SystemSwitch.ReleaseMode) { return(FileAccessManager.LoadText(fileName)); } else { if (SystemConfig.IsEditor) { return(Utils.LoadFile(String.Concat(SystemConfig.DataPath, "/Resources/", fileName))); } else { return(Utils.LoadResource(fileName)); } } } catch (Exception ex) { LoggerHelper.Except(ex); return(""); } }
public static string LoadText(string fileName) { try { return(SystemSwitch.ReleaseMode ? FileAccessManager.LoadText(fileName) : Utils.LoadResource(fileName)); } catch (Exception exception) { LoggerHelper.Except(exception, null); return(""); } }
public static string LoadText(string fileName) { try { if (SystemSwitch.ReleaseMode) { return(FileAccessManager.LoadText(fileName)); } if (SystemConfig.IsEditor) { return(Utils.LoadFile(SystemConfig.DataPath + "/Resources/" + fileName)); } return(Utils.LoadResource(fileName)); } catch (Exception exception) { LoggerHelper.Except(exception, null); return(""); } }
public static void LoadMetaOfResource(string path, Action cb = null) { //meta现已全部拷到sd卡 //if (!File.Exists(Path.Combine(SystemConfig.ResourceFolder, path))) //{ // Driver.Instance.StartCoroutine(Driver.Instance.LoadWWWText(Utils.GetStreamPath(path), // (xmlText) => // { // var xml = XMLParser.LoadXML(xmlText); // if (xml == null) // { // if (cb != null) // { // cb(); // } // return; // } // foreach (SecurityElement item in xml.Children) // { // var meta = new ResourceMetaData(); // meta.RelativePath = item.Attribute("path"); // meta.MD5 = item.Attribute("md5"); // var dependencies = item.Children; // if (dependencies != null && dependencies.Count > 0) // { // meta.Dependencies = new List<string>(); // foreach (SecurityElement dependency in dependencies) // { // meta.Dependencies.Add(dependency.Attribute("path")); // } // } // metaOfResource[meta.RelativePath] = meta; // } // if (cb != null) // { // cb(); // } // })); //} //else //{ var xml = XMLParser.LoadXML(FileAccessManager.LoadText(path)); if (xml == null) { if (cb != null) { cb(); } return; } for (int i = 0; i < xml.Children.Count; i++) { SecurityElement item = xml.Children[i] as SecurityElement; var meta = new ResourceMetaData(); meta.RelativePath = item.Attribute("path"); meta.MD5 = item.Attribute("md5"); var dependencies = item.Children; if (dependencies != null && dependencies.Count > 0) { meta.Dependencies = new List <string>(); foreach (SecurityElement dependency in dependencies) { meta.Dependencies.Add(dependency.Attribute("path")); } } metaOfResource[meta.RelativePath] = meta; } if (cb != null) { cb(); } //} }
public static void LoadMetaOfMeta(Action cb, Action <int, int> process) { metaOfMeta = new Dictionary <string, string>(); //meta现已全部拷到sd卡 //if (!File.Exists(Path.Combine(SystemConfig.ResourceFolder, ResourceManager.MetaFileName))) //{ // Driver.Instance.StartCoroutine(Driver.Instance.LoadWWWText(Utils.GetStreamPath(ResourceManager.MetaFileName), // (xmlText) => // { // var xml = XMLParser.LoadXML(xmlText); // if (xml == null) // { // if (cb != null) // { // cb(); // } // return; // } // foreach (SecurityElement item in xml.Children) // { // metaOfMeta[item.Attribute("path")] = item.Attribute("md5"); // } // RecursiveLoadMetaOfResource(metaOfMeta.Keys.ToList(), 0, metaOfMeta.Keys.Count, () => // { // AssetCacheMgr.AssetMgr.SetPathMap(); // if (cb != null) // { // cb(); // } // }, process); // })); //} //else //{ Action action = () => { var xml = XMLParser.LoadXML(FileAccessManager.LoadText(ResourceManager.MetaFileName)); if (xml == null) { if (cb != null) { #if UNITY_ANDROID Driver.Invoke(cb); #elif UNITY_IPHONE Driver.Invoke(cb); #else Driver.Invoke(cb); #endif } return; } for (int i = 0; i < xml.Children.Count; i++) { SecurityElement item = xml.Children[i] as SecurityElement; metaOfMeta[item.Attribute("path")] = item.Attribute("md5"); } RecursiveLoadMetaOfResource(metaOfMeta.Keys.ToList(), 0, metaOfMeta.Keys.Count, () => { AssetCacheMgr.AssetMgr.SetPathMap(); if (cb != null) { #if UNITY_ANDROID Driver.Invoke(cb); #elif UNITY_IPHONE Driver.Invoke(cb); #else Driver.Invoke(cb); #endif } }, process); }; action.BeginInvoke(null, null); //} }