示例#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);
        }
示例#2
0
        /// <summary>
        /// 删除过期的资源
        /// </summary>
        /// <param name="obsoleteBundles"></param>
        private void RemoveObsoleteBundle(List <BundleIndexItemInfo> obsoleteBundles)
        {
            for (int i = 0; i < obsoleteBundles.Count; ++i)
            {
                string obsoleteBundlePath;
                if (EngineFileUtil.IsExistInPersistentDataPath(obsoleteBundles[i].BundleHashName, out obsoleteBundlePath))
                {
                    File.Delete(obsoleteBundlePath);
                }
            }

            bundleMapLocal.DeleteBundleList(obsoleteBundles);
        }
示例#3
0
        public List <BundleIndexItemInfo> GetDynamicBundleIndexItemListByAssets(List <string> assetNameList)
        {
            if (RemoteBundleIndicesMap == null && DiffResult == null)
            {
                return(null);
            }

            List <BundleIndexItemInfo> dynamicBundleList = new List <BundleIndexItemInfo>();

            for (int i = assetNameList.Count - 1; i >= 0; --i)
            {
                string assetName = assetNameList[i];
                BundleIndexItemInfo dynamicBundleIndexItemInfo;
                dynamicBundleIndexItemInfo = DiffResult.GetAppendBundleItemInfoByBundleName(assetName);
                if (dynamicBundleIndexItemInfo != null)
                {
                    string dynamicBundlePath;
                    if (!EngineFileUtil.IsExistInPersistentDataPath(dynamicBundleIndexItemInfo.BundleHashName, out dynamicBundlePath))
                    {
                        dynamicBundleList.Add(dynamicBundleIndexItemInfo);
                    }
                    else
                    {
                        //OnDownloadedAsset(dynamicBundleIndexItemInfo.BundleHashName, null);
                        ResourceMgr.Instance.BundleMap.AddBundleIndicesByTransaction(dynamicBundleIndexItemInfo.BundleName, dynamicBundleIndexItemInfo.BundleHash, dynamicBundleIndexItemInfo.BundleDependencyArray, dynamicBundleIndexItemInfo.BundleAssetsArray, dynamicBundleIndexItemInfo.BundleSize);
                    }

                    assetNameList.Remove(assetName);
                }
            }

            List <BundleIndexItemInfo> assetBelongBundleList = RemoteBundleIndicesMap.GetBundleItemInfoListByAssetsList(assetNameList);

            for (int i = 0; i < assetBelongBundleList.Count; ++i)
            {
                BundleIndexItemInfo bundleItemInfo = DiffResult.GetAppendBundleItemInfoByBundleName(assetBelongBundleList[i].BundleName);
                if (bundleItemInfo != null)
                {
                    dynamicBundleList.Add(bundleItemInfo);
                }
            }

            return(dynamicBundleList);
        }