Beispiel #1
0
        // 4.下载最新的文件索引
        private IEnumerator DownloadLatestIndex()
        {
            if (GameConfig.PLATFORM == null)
            {
                yield break;
            }

            byte[] bytes = null;
            string url   = _updateSetting.resUrl + _latestVersion + '-' + GameConfig.PLATFORM + "/media/file.list?spm=" + GetRandomValue();

            //	Debug.Log("Updater.DownloadLatestIndex " + url);

            for (int i = 0; i < DOWNLOAD_RETRY_TIMES; i++)
            {
                WWW downloader = new WWW(url);
                yield return(downloader);

                // 下载成功
                if (downloader.error == null)
                {
                    bytes = downloader.bytes;
                    break;
                }

                yield return(new WaitForSeconds(DOWNLOAD_RETRY_DELAY));
            }

            if (bytes == null)
            {
                yield break;
            }

            try
            {
                _latest = new AssetIndexFile();
                _latest.Load(new MemoryStream(bytes), AssetInfo.STORAGE_PERSISTEN);
            }
            catch (Exception)
            {
                _latest = null;
            }
        }