Example #1
0
        private void OnPostDiff(BundleIndicesMap.BundleMapDiffResult diffResult)
        {
            for (int i = 0; i < diffResult.ObsoleteBundleIndexList.Count; ++i)
            {
                BundleIndexItemInfo obsoleteBundleInfo = diffResult.ObsoleteBundleIndexList[i];
                string bundleInPersistent;
                if (EngineFileUtil.IsExistInPersistentDataPath(obsoleteBundleInfo.BundleHashName, out bundleInPersistent))
                {
                    File.Delete(bundleInPersistent);
                }
            }

            ResourceMgr.Instance.BundleMap.DeleteBundleList(diffResult.ObsoleteBundleIndexList);

            diffResult.ObsoleteBundleIndexList.Clear();

            //已经下载但没写入bundlemap的资源
            for (int i = 0; i < diffResult.DirtyBundleIndexList.Count; ++i)
            {
                BundleIndexItemInfo dirtyBundleItemInfo = diffResult.DirtyBundleIndexList[i];

                string bundleInPersistent;
                if (EngineFileUtil.IsExistInPersistentDataPath(dirtyBundleItemInfo.BundleHashName, out bundleInPersistent))
                {
                    //OnDownloadedAsset(dirtyBundleItemInfo.BundleHashName, null);

                    ResourceMgr.Instance.BundleMap.AddBundleIndicesByTransaction(dirtyBundleItemInfo.BundleName, dirtyBundleItemInfo.BundleHash, dirtyBundleItemInfo.BundleDependencyArray, dirtyBundleItemInfo.BundleAssetsArray, dirtyBundleItemInfo.BundleSize);

                    diffResult.DirtyBundleIndexList.RemoveAt(i);
                }
            }

            m_downloadIndexDict.Clear();
            RegisterDownloadBundleList(diffResult.DirtyBundleIndexList);
        }
Example #2
0
        public void CheckUpdate(Action <BundleIndicesMap.BundleMapDiffResult> NeedUpdateCallback)
        {
            if (this.m_remoteBundleIndicesMap != null && DiffResult != null)
            {
                NeedUpdateCallback(DiffResult);
            }
            else
            {
                SyncRemoteBundlemap(() =>
                {
                    EngineCoreEvents.ResourceEvent.OnDownloadedAssetFromWebServer += OnDownloadedAsset;
                    EngineCoreEvents.ResourceEvent.OnFinishDownloadUpdateEvent    += OnFinishUpdateAssets;

                    DiffResult = ResourceMgr.Instance.BundleMap.Diff(this.m_remoteBundleIndicesMap.BundleIndicesMapConn, false);
                    OnPostDiff(DiffResult);

                    NeedUpdateCallback(DiffResult);
                });
            }
        }