Exemplo n.º 1
0
    private void Start()
    {
        ResUpdateInfo info = new ResUpdateInfo();

        info.CategoryId = 1;
        info.PrefabList = new[]
        {
            "category_1/block_prefabs/paiblock_feat_signboard_light_purple",
        };

        info.ThumbList = new []
        {
            "category_1/block_thumbs/paiblock_feat_signboard_light_purple"
        };

        PTBlockResUpdator updator = gameObject.AddComponent <PTBlockResUpdator>();

        updator.UpdateRes(info);
    }
Exemplo n.º 2
0
        private IEnumerator WaitUpdateRes(ResUpdateInfo info)
        {
            mCategoryId = info.CategoryId;

            //1............................................
            GetResConfig(mCategoryId);
            while (mState != DownloadState.ResConfigFinish)
            {
                if (mState == DownloadState.Error)
                {
                    yield break;
                }
                yield return(null);
            }

            //2............................................
            GetABManifest(mCategoryId);
            while (mState != DownloadState.ABManifestFinish)
            {
                if (mState == DownloadState.Error)
                {
                    yield break;
                }
                yield return(null);
            }

            //3............................................
            if (info.PrefabList != null && info.PrefabList.Length > 0)
            {
                List <ResConfigItem> downloadList = GetDownloadList(info.PrefabList);
                if (mState == DownloadState.Error)
                {
                    yield break;
                }
                if (downloadList.Count > 0)
                {
                    UpdateState(DownloadState.Prefabs);
                    yield return(DownloadRes(downloadList));

                    if (mState == DownloadState.Error)
                    {
                        yield break;
                    }
                    UpdateState(DownloadState.PrefabsFinish);
                }
            }

            //4............................................
            if (info.ThumbList != null && info.ThumbList.Length > 0)
            {
                List <ResConfigItem> downloadList = GetDownloadList(info.ThumbList);
                if (mState == DownloadState.Error)
                {
                    yield break;
                }
                if (downloadList.Count > 0)
                {
                    UpdateState(DownloadState.Thumbs);
                    yield return(DownloadRes(downloadList));

                    if (mState == DownloadState.Error)
                    {
                        yield break;
                    }
                    UpdateState(DownloadState.ThumbsFinish);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新&下载资源
 /// 1.本地是否存在。
 //	2.存在则比对md5. 不一样则下载  根据block.manifest 遍历处理依赖
 //	3.不存在则下载               根据block.manifest 遍历处理依赖
 /// </summary>
 public void UpdateRes(ResUpdateInfo info)
 {
     StartCoroutine(WaitUpdateRes(info));
 }