Example #1
0
        public void DoStreamAssetDecompress(AssetUpdateMgr parent, Action finishCallback)
        {
            LogMgr.UnityError(Time.realtimeSinceStartup.ToString());

            mParent         = parent;
            mFinishCallback = finishCallback;

            mParent.UpdateProgress("正从本地解压缩资源(此过程不消耗流量)", 0f);

            mStreamFiles.Clear();
            string abtoFile = string.Format("{0}/{1}/Inner/{2}", Application.persistentDataPath, BundleCommon.ResVersion, BundleCommon.AssetBundleManifest);

            if (!File.Exists(abtoFile))
            {
                mStreamFiles.Add("/" + BundleCommon.AssetBundleManifest);
            }

            List <AssetBundleConfig> streamConfigs = XMLTool.LoadAllABConfig(BundleCommon.StreamUserVersionPath, true);

            if (null != streamConfigs)
            {
                for (int i = 0; i < streamConfigs.Count; i++)
                {
                    string toFilePath = Application.persistentDataPath + "/" + BundleCommon.ResVersion + "/Inner" + streamConfigs[i].RelativePath;
                    string toFileDir  = toFilePath.Remove(toFilePath.LastIndexOf("/"));
                    if (!Directory.Exists(toFileDir))
                    {
                        Directory.CreateDirectory(toFileDir);
                    }

                    if (!File.Exists(toFilePath))
                    {
                        mStreamFiles.Add(streamConfigs[i].RelativePath);
                    }
                }
            }
            mCurCopyNum    = 0;
            mMaxCopyNum    = 5;
            mFinishCopyNum = 0;
            mTotalCopyNum  = mStreamFiles.Count;
            if (mTotalCopyNum != 0)
            {
                CopyAsset();
            }
            else
            {
                mParent.UpdateProgress("正从本地解压缩资源(此过程不消耗流量)", 1f);
                if (null != mFinishCallback)
                {
                    mFinishCallback();
                }
            }
        }
Example #2
0
        /// <summary>
        /// 下载
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="sizeData"></param>
        /// <param name="finishCallBack"></param>
        public void BeginDownLoadAsset(DownLoadType type, AssetUpdateMgr parent, DownloadAssetSizeCaculate sizeData, FinishDelegate finishCallBack)
        {
            mDownloadType = type;
            mParent       = parent;
            mCurrentDownloadAssetSizeCaculate = sizeData;
            mFinishCallBack = finishCallBack;

            if (null == sizeData.mVersionDataConfig || 0 == sizeData.mVersionDataConfig.Count)
            {
                CallBackDownLoadSucess();

                return;
            }

            mNewVersionDataConfig = sizeData.mVersionDataConfig;
            mAllVersionDataDic.Clear();

            if (mDownloadType == DownLoadType.FIRST_PHASE && null != mParent)
            {
                mParent.UpdateProgress("开始下载更新资源文件", 0);
            }

            mMaxDownLoadCount = mDownloadType == DownLoadType.FIRST_PHASE ? 8 : 3;
            DownLoadAsset();
            mDownLoadAssetCount = mNewVersionDataConfig.Count;
        }
Example #3
0
        /// <summary>
        /// 下载回调
        /// </summary>
        /// <param name="success"></param>
        /// <param name="resVersionData"></param>
        private void OnDownLoadAsset(bool success, AssetBundleConfig resVersionData)
        {
            if (success)
            {
                mCurrentDownloadAssetSizeCaculate.OnAssetDownLoad(resVersionData);
                float progress = mCurrentDownloadAssetSizeCaculate.CurrentDownloadSize / mCurrentDownloadAssetSizeCaculate.MaxSize;

                if (mDownloadType == DownLoadType.FIRST_PHASE && null != mParent)
                {
                    mParent.UpdateProgress(string.Format("正在下载更新{0}M/{1}M", mCurrentDownloadAssetSizeCaculate.CurrentDownLoadFileSize, mCurrentDownloadAssetSizeCaculate.AllFileSize), progress);
                }
                else
                {
                    CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_Bundle_Group_Download_Progress, EventParameter.Get(progress));
                    LogMgr.UnityLog("Bundle group " + mCurrentDownloadAssetSizeCaculate.CurBuild + " progress, " + progress);
                }
            }
            else
            {
                mDownLoadErrorVersionDataConfig.Add(resVersionData);
            }

            mCurrentDownLoadCount--;
            if (mNewVersionDataConfig.Count == 0 && mCurrentDownLoadCount == 0)
            {
                if (mDownLoadErrorVersionDataConfig.Count <= 0)
                {
                    CallBackDownLoadSucess();
                }
                else
                {
                    OnDownLoadError();
                }
            }
        }
Example #4
0
        private void FinishCopy()
        {
            mFinishCopyNum++;
            mParent.UpdateProgress("正从本地解压缩资源(此过程不消耗流量)", mFinishCopyNum * 1.0f / mTotalCopyNum);

            mCurCopyNum--;
            CopyAsset();

            if (mCurCopyNum == 0 && mStreamFiles.Count == 0)
            {
                mParent.UpdateProgress("正从本地解压缩资源(此过程不消耗流量)", 1f);
                if (null != mFinishCallback)
                {
                    LogMgr.UnityError(Time.realtimeSinceStartup.ToString());
                    mFinishCallback();
                }
            }
        }
Example #5
0
 private void UpdateGetVersionProgress(float progress)
 {
     mParent.UpdateProgress("正在获取资源版本", progress);
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="progress"></param>
 private void UpdateGetUrlProgress(float progress)
 {
     mParent.UpdateProgress("正在获取更新资源地址", progress);
 }
Example #7
0
 /// <summary>
 /// 下载更新进度
 /// </summary>
 /// <param name="progress"></param>
 private void UpdateLoadCompressProgress(float progress)
 {
     mParent.UpdateProgress("正在读取资源文件", mFValue + progress * mDValue);
 }