private void btn_07() { var path = Application.persistentDataPath; //开始下载 BResources.StartAssetsVersionControl(UpdateMode.Repair, "http://127.0.0.1", null, (idx, totalNum) => { //进度通知 Debug.LogFormat("资源更新进度:{0}/{1}", idx, totalNum); }, (status, msg) => { //错误通知 Debug.LogError("结果:" + status + " - " + msg); }); }
/// <summary> /// 下载且启动 /// </summary> private void OnClick_DownLoadAndLaunch() { Debug.Log(Application.persistentDataPath); var url = "http://" + this.inputField.text; float totalSize = -1; float curDoanloadSize = -1; BResources.StartAssetsVersionControl(UpdateMode.CompareWithRepair, url, null, (curDownload, allDownloadList) => { if (totalSize == -1) { foreach (var item in allDownloadList) { totalSize += item.FileSize; } curDoanloadSize = 0; } curDoanloadSize += curDownload.FileSize; //进度通知,显示下载的 this.text_DownloadProcess.text = string.Format("{0}KB / {1}KB", curDoanloadSize, totalSize); }, (status, msg) => { //下载状态 switch (status) { case AssetsVersionController.RetStatus.Success: { this.text_DownloadProcess.text = "下载完毕"; //启动 // this.Onclick_PassAndLaunch(); } break; case AssetsVersionController.RetStatus.Error: { //错误 this.text_DownloadProcess.text = msg; } break; } }); }
/// <summary> /// 下载分包且启动 /// </summary> private void Onclick_DownloadSubPackageLoadAndLaunch(string subPackageName) { Debug.Log(Application.persistentDataPath); var url = "http://" + this.inputField.text; float totalSize = -1; float curDoanloadSize = -1; BResources.StartAssetsVersionControl(UpdateMode.Compare, url, subPackageName, (curDownload, allDownloadList) => { if (totalSize == -1) { foreach (var item in allDownloadList) { totalSize += item.FileSize; } curDoanloadSize = 0; } curDoanloadSize += curDownload.FileSize; //进度通知` this.text_DownloadProcess.text = string.Format("{0}KB / {1}KB", curDoanloadSize, totalSize); }, (status, msg) => { switch (status) { case AssetsVersionController.RetStatus.Success: { this.text_DownloadProcess.text = "下载完毕"; Debug.Log("分包下载完毕,此时资源不全,进入游戏可能会有bug!"); } break; case AssetsVersionController.RetStatus.Error: { //错误 this.text_DownloadProcess.text = msg; } break; } }); }