private IEnumerator DownloadAllAsync(string assetHostURL, List <string> bundleNames) { foreach (var bundleName in bundleNames) { string url = System.IO.Path.Combine(assetHostURL, bundleName + ".bundle"); DownloadTask download = new DownloadTask(url); this.mDownloadList[bundleName] = download; } foreach (var bundleName in bundleNames) { DownloadTask download = null; this.mDownloadList.TryGetValue(bundleName, out download); if (download == null) { continue; } yield return(download.Download()); int count = 0; while (count <= 3 && !string.IsNullOrEmpty(download.www.error)) { count++; yield return(download.Download()); } if (!string.IsNullOrEmpty(download.www.error)) { Debug.LogError(download.www.error + "\n" + download.url); yield break; } byte[] data = download.www.bytes; Autarky.Signature sig_v3; if (Autarky.DecodeSignature(data, out sig_v3)) { BundleInfo info = null; if (this.mAssetManifest.TryGetValue(bundleName, out info)) { info.localVersion = sig_v3.version; } string localBundlePath = AssetPath.LocalBundlePath(bundleName); if (System.IO.File.Exists(localBundlePath)) { System.IO.File.Delete(localBundlePath); } XFile.WriteBytesFile(localBundlePath, data, 0, data.Length); download.Done(); System.GC.Collect(); } else { Debug.LogErrorFormat( "Bundle download successfully but file format is invalid. \n url : {0} \n bundleName : {1} \n error : {2}", assetHostURL, bundleName, Autarky.error); } } }
private bool GetBundleInfo(byte[] data, ref BundleInfo info) { Autarky.Signature sig_v3; if (Autarky.DecodeSignature(data, out sig_v3)) { info.localVersion = sig_v3.version; return(true); } return(false); }
private bool GetLocalBundleInfo(string bundleName, ref BundleInfo info) { string bundlePath = AssetPath.LocalBundlePath(bundleName); Autarky.Signature sig_v3; if (Autarky.DecodeSignature(bundlePath, out sig_v3)) { info.localVersion = sig_v3.version; return(true); } return(false); }