Esempio n. 1
0
        public void AbortUpdate()
        {
            StopAllCoroutines();
            if (m_Verify != null)
            {
                m_Verify.Abort();
                m_Verify = null;
            }

            if (m_Downloader != null)
            {
                m_Downloader.Abort();
                m_Downloader = null;
            }

            if (m_FileDownload != null)
            {
                m_FileDownload.Abort();
                m_FileDownload = null;
            }

            SaveDownloadCacheData();
            OnUpdateState(State.Abort);
            Done();
        }
Esempio n. 2
0
        /// <summary>
        /// 更新AB资源
        /// </summary>
        /// <returns></returns>
        IEnumerator StartUpdateAssetBundle()
        {
            if (errorCode != ErrorCode.None)
            {
                yield break;
            }

            UpdateCompleteValue(0f, 0f);
            //载入ResourceManifest
            var oldResManifestFile = OnLoadResourceFile();
            var path = PathResolver.GetCacheFileFullName(PathResolver.RESOURCES_MANIFEST_FILE_NAME);
            var newResManifestFile = PathResolver.LoadResourceManifestByPath(path);

            if (null == newResManifestFile)
            {
                Error(ErrorCode.loadNewResourcesManiFestFailed, "Can't Load new version ResourceManifest");
                yield break;
            }

            //载入MainManifest
            var oldManifest = PathResolver.LoadMainManifest();
            var newManifest = PathResolver.LoadCacheMainManifest();

            if (null == newManifest)
            {
                Error(ErrorCode.LoadNewMainManifestFailed, "can't load new version MainManifest");
                yield break;
            }

            var downFiles   = new List <string>();
            var deleteFiles = new List <string>();

            CompareAsset(ref downFiles, ref deleteFiles, oldManifest, newManifest, oldResManifestFile, newResManifestFile);

            //删除废气文件
            if (deleteFiles.Count > 0)
            {
                for (int i = 0; i < deleteFiles.Count; ++i)
                {
                    var fullName = PathResolver.GetFileFullName(deleteFiles[i]);
                    if (File.Exists(fullName))
                    {
                        File.Delete(fullName);
                        yield return(0);
                    }
                }
            }

            //更新下载资源
            m_Downloader = new AssetBundleDownloader(m_CurUrl);
            m_Downloader.Start(PathResolver.PATH, downFiles, newResManifestFile);
            while (!m_Downloader.isDone)
            {
                UpdateCompleteValue(m_Downloader.completedSize, m_Downloader.totalSize);
                yield return(0);
            }
            if (m_Downloader.isFailed)
            {
                Error(ErrorCode.DonwloadAssetBundleFailed);
                yield break;
            }
        }