private void EndReadBytes(byte[] data, object obj) { if (data == null) { SetOver(); return; } MemoryStream ms = new MemoryStream(data); relationFile = RelationFile.Deserialize(ms); if (relationFile != null) { CoroutineHelper.CreateCoroutineHelper(LoadAsset(relationFile)); } else { SetOver(); } }
private IEnumerator LoadAsset(RelationFile rf) { if (rf.Nodes.Count == 0) { SetOver(); yield break; } var node = rf.Nodes[0]; if (node.Nodes.Count() > 0) { LayerLoadParam layerParam = new LayerLoadParam(); layerParam.layer = 0; layerParam.num = 0; for (int i = 0, count = node.Nodes.Count; i < count; i++) { CoroutineHelper.CreateCoroutineHelper(LoadBundle(node.Nodes[i], layerParam)); } while (layerParam.num >= 0 && layerParam.num < node.Nodes.Count()) { yield return(null); } if (layerParam.num < 0) { UnLoad(); SetOver(); yield break; } } ResLoader.LoadByName(node.File, EndLoadAsset, new LoadInfo() { name = node.File, param = null }); }
private void Collect(string root) { string[] paths = Directory.GetFiles(root); if (paths != null) { string fileName = null; for (int i = 0, count = paths.Length; i < count; i++) { fileName = Path.GetFileName(paths[i]); if (files.ContainsKey(fileName)) { Debug.LogError("duplicate files->" + files[fileName] + "^" + paths[i]); continue; } if (fileName == null || fileName == "") { continue; } string path = paths[i]; string suffix = Path.GetExtension(path); if (suffix == ".cf") { RelationData rd = new RelationData(); rd.origin = fileName; rd.dest = fileName; rd.path = path; rd.encrypt = false; rd.fileType = VersionFile.Type.COMBINE_FILE; files.Add(fileName, rd); CombineFile cf = new CombineFile(fileName); List <string> lst = new List <string>(); cf.CollectAllFilePath(lst); for (int a = 0, acount = lst.Count; a < acount; a++) { files.Add(lst[a], rd); } } else if (suffix == ".rf") { RelationData rd = new RelationData(); rd.origin = fileName; rd.dest = fileName; rd.path = path; rd.encrypt = false; rd.fileType = VersionFile.Type.RELATION_FILE; files.Add(fileName, rd); using (FileStream fs = File.OpenRead(path)) { var rf = RelationFile.Deserialize(fs); files.Add(rf.Name, rd); } } else { RelationData rd = new RelationData(); rd.origin = fileName; rd.dest = fileName; rd.path = path; rd.encrypt = false; rd.fileType = VersionFile.Type.DEFAULT; files.Add(fileName, rd); } } } string[] dirs = Directory.GetDirectories(root); if (dirs != null) { for (int i = 0, count = dirs.Length; i < count; i++) { Collect(dirs[i]); } } }