IEnumerator UpdateGroups(string[] needUpdateResList) { //实例化一个资源组下载器 GroupDownloader groupLoader = new GroupDownloader(); foreach (var resName in needUpdateResList) { var netItem = Runtime.Ins.netResVer.Get(resName); //将要下载的文件依次添加入下载器 groupLoader.AddLoad(FileSystem.CombinePaths(Runtime.Ins.netResDir, resName), FileSystem.CombinePaths(Runtime.Ins.localResDir, resName), netItem.version, netItem.size, OnItemLoaded, netItem); } //启动下载器开始下载 groupLoader.StartLoad(); //判断是否所有资源下载完成,如果没有,返回一个下载的进度(该进度表示的整体进度) do { _onProgress.Invoke(groupLoader.Progress, groupLoader.TotalSize); yield return(new WaitForEndOfFrame()); }while (false == groupLoader.IsDone); //判断下载是否返回错误 if (null != groupLoader.Error) { if (null != _onError) { _onError.Invoke(groupLoader.Error); } yield break; } _onComplete(); }
IEnumerator UpdateGroups(HashSet <string> itemSet) { //实例化一个资源组下载器 GroupDownloader groupLoader = new GroupDownloader(); foreach (var itemName in itemSet) { string localVer = Runtime.Ins.localResVer.GetVer(itemName); var netItem = Runtime.Ins.netResVer.Get(itemName); if (localVer != netItem.version) { //将要下载的文件依次添加入下载器 groupLoader.AddLoad(Runtime.Ins.netResDir + itemName, Runtime.Ins.localResDir + itemName, netItem.version, OnItemLoaded, netItem); } } //启动下载器开始下载 groupLoader.StartLoad(); //判断是否所有资源下载完成,如果没有,返回一个下载的进度(该进度表示的整体进度) do { _onProgress.Invoke(groupLoader.progress); yield return(new WaitForEndOfFrame()); }while (false == groupLoader.isDone); //判断下载是否返回错误 if (null != groupLoader.error) { Log.E("下载出错:{0}", groupLoader.error); yield break; } _onComplete(); }