Пример #1
0
        //依据记录的资源更新列表覆盖更新本地资源
        IEnumerator IUpdateAllBundles()
        {
            string strUpdateInfo = FileTool.ReadFile(RecsPathCtrl.GetIns().GetPathUpdateInfoFile(true), Encoding.UTF8, () => Log.LogAndSave("读取资源更新列表完毕"));

            MsgUICtrl.GetIns().ShowMsg("读取资源更新列表完毕", strUpdateInfo, null, true, 0.5f);

            string[] updateList = strUpdateInfo.Split('\n', '\r');
            for (int i = 0; i < updateList.Length; i++)
            {
                if (string.IsNullOrEmpty(updateList[i].Trim()))
                {
                    continue;
                }

                LoadRecsUI.GetIns().InitAndShow(string.Format("更新资源[{0}]", updateList[i]), true, i * 1f / updateList.Length * 1f);
                yield return(StartCoroutine(AssetBundleTool.DownloadAssetBundle(RecsPathCtrl.GetIns().RecsRootPathServer, updateList[i], RecsPathCtrl.GetIns().RecsRootPathLocal,
                                                                                (error) => { MsgUICtrl.GetIns().ShowMsg("更新资源失败", error, null, true, 1); },
                                                                                null
                                                                                )));

#if UNITY_EDITOR//测试
                yield return(new WaitForSeconds(0.05f));
#endif
            }
            LoadRecsUI.GetIns().InitAndShow(string.Format("更新资源完成"), true, 1);


            //刷新本地的Manifest
            //  yield return StartCoroutine(IUpdateManifestToLocal());


            yield return(null);
        }
Пример #2
0
        //一次性从服务器将所有AssetBundle文件下载到本地缓存
        IEnumerator IDownAllBundlesFromServerToLocal()
        {
            //更新Manifest至本地
            yield return(StartCoroutine(IUpdateManifestToLocal()));

            //显示读取信息
            Log.LogAndSave("下载根数据成功");
            MsgUICtrl.GetIns().ShowMsg("下载根数据成功", "将根数据保存至本地 " + RecsPathCtrl.GetIns().GetPathManifest(true), null, true);


            //获取Manifest包含的所有的AssetBundle信息
            string[] arrAllBundles = ManifestServer.GetAllAssetBundles();

            if (arrAllBundles == null || arrAllBundles.Length == 0)
            {
                MsgUICtrl.GetIns().ShowMsg("空资源", "根数据下没有其它资源 ", null, true, 1);
                Log.LogAndSave("根数据下没有其它资源");
                yield break;
            }

            //下载所有的AssetBundle文件到本地
            for (int i = 0; i < arrAllBundles.Length; i++)
            {
                LoadRecsUI.GetIns().InitAndShow(string.Format("下载资源[{0}]", arrAllBundles[i]), true, i * 1f / arrAllBundles.Length);
                yield return(StartCoroutine(AssetBundleTool.DownloadAssetBundle(
                                                RecsPathCtrl.GetIns().RecsRootPathServer
                                                , arrAllBundles[i],
                                                RecsPathCtrl.GetIns().RecsRootPathLocal,
                                                (string str) =>
                {
                    Log.LogAndSave("下载资源失败 " + str);
                    MsgUICtrl.GetIns().ShowMsg("下载资源失败", str, null, true, 1);
                },
                                                () => LoadRecsUI.GetIns().InitAndShow(string.Format("下载资源[{0}]}", arrAllBundles[i]), true, (i + 1) * 1f / arrAllBundles.Length))));


#if UNITY_EDITOR//测试
                yield return(new WaitForSeconds(0.05f));
#endif
            }

            LoadRecsUI.GetIns().InitAndShow(string.Format("下载资源成功"), true, 1);
            yield return(new WaitForSeconds(1));

            yield return(null);
        }