static void ParseObject(loadNode node, object obj) { if (node.isSave) { string saveName = node.path.Substring(node.path.LastIndexOf('/') + 1); dict.Add(saveName, obj); } if (node.action != null) { //AssetBundle ab = ((DownloadHandlerAssetBundle)(request.downloadHandler)).assetBundle; node.action(obj); } }
static IEnumerator DownLoad(loadNode node) { LoadFactory.loadText = node.path; LoadFactory.www = new WWW(node.path); yield return(LoadFactory.www); if (string.IsNullOrEmpty(LoadFactory.www.error)) { loadType type = node.type; switch (type) { case loadType.Wwwbytes: LoadFactory.ParseObject(node, LoadFactory.www.bytes); break; case loadType.AssetBundle: LoadFactory.ParseObject(node, LoadFactory.www.assetBundle); break; case loadType.Texture: LoadFactory.ParseObject(node, LoadFactory.www.texture); break; case loadType.Text: LoadFactory.ParseObject(node, LoadFactory.www.text); break; case loadType.Xml: LoadFactory.ParseXML(node, LoadFactory.www.text); break; case loadType.AudioClip: LoadFactory.ParseObject(node, LoadFactory.www.GetAudioClip()); break; } //LoadFactory.www = null; //Debug.Log("loadFactory.www>>>>>>>>>>>>>>> "); LoadFactory.loadText = "加载完成"; LoadFactory.NextLoad(); } else { // LoadFactory.www = null; LoadFactory.loadText += " - 加载出错:" + www.error; Debug.Log("加载出错: " + www.error); LoadFactory.NextLoad(); } }
static void ParseXML(loadNode node, string xmlstr) { XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlstr); if (node.isSave) { string saveName = node.path.Substring(node.path.LastIndexOf('/') + 1); dict.Add(saveName, xmldoc); } if (node.action != null) { //AssetBundle ab = ((DownloadHandlerAssetBundle)(request.downloadHandler)).assetBundle; node.action(xmldoc, LoadFactory.www.bytes); } }
private static void NextLoad() { if (paths.Count > 0) { loadNode node = paths.Dequeue(); node.parent.StartCoroutine(DownLoad(node)); } else { if (loadAllComplate != null) { loadAllComplate(); loadAllComplate = null; } } }
static void ParseObject(loadNode node, object obj) { if (node.isSave) { string saveName = node.path.Substring(node.path.LastIndexOf('/') + 1); dict.Add(saveName, obj); } if (node.action != null) { //AssetBundle ab = ((DownloadHandlerAssetBundle)(request.downloadHandler)).assetBundle; if (node.type == loadType.AssetBundle) { LoadFactory.www.assetBundle.Unload(false); } node.action(obj, LoadFactory.www.bytes); } }