private void OnloadComplete(BundleVo bundle) { loadList.RemoveAt(0); if (loadList.Count > 0) { StartLoadBundle(); } }
/// <summary> /// Loads the bundles. /// </summary> /// <param name="nameWithVersion">Name with version.</param> private void LoadBundles(string nameWithVersion) { string[] nameVersionSize = nameWithVersion.Split('_'); string bundleName = nameVersionSize [0]; string bundleVersion = nameVersionSize [1]; string[] ver_size = bundleVersion.Split('@'); string bundleSize = ver_size [1]; Debug.Log("进入下载队列文件:" + bundleName + "|" + bundleVersion + "|" + bundleSize); if (voManager.hasBundle(bundleName)) { Debug.Log("已经下载和Addbundle的" + bundleName); return; } BundleVo bundle = new BundleVo(nameWithVersion); bundle.name = bundleName; bundle.chunckSize = int.Parse(bundleSize); if (filenameDict.ContainsKey(bundleName)) { if (filenameDict [bundleName].Equals(bundleVersion)) { bundle.isLoadFromFile = true; OnloadComplete(bundle); } else { string filepath = LMVersion.ASSET_BUNDLE_PATH + "_" + filenameDict [bundleName]; DirectoryInfo dirinfo = new DirectoryInfo(LMVersion.ASSET_BUNDLE_PATH); FileInfo[] infos = dirinfo.GetFiles(); foreach (FileInfo fl in infos) { Debug.Log(fl); if (fl.Name.IndexOf(bundleName) > -1 && fl.Name.Substring(0, fl.Name.LastIndexOf('_')).Length == bundleName.Length) { //找到开头一样,文件名开头长度一样的文件删掉 File.Delete(fl.FullName); Debug.Log("删除文件" + fl.FullName); filenameDict [bundleName] = bundleVersion; break; } } bundle.StartDownload(OnloadComplete, OnLoadProgress, OnLoadError); } } else { bundle.StartDownload(OnloadComplete, OnLoadProgress, OnLoadError); } voManager.addBundle(bundle); }
public void addBundle(BundleVo vo) { tbBundleVo.Add(vo.name, vo); }