Ejemplo n.º 1
0
 internal void GetBundle(XBundleData bundle, string url, HandleBundleDownload callback1, HandleFetchBundle callback2, float percent)
 {
     this._download      = url.Contains("?token=");
     this._current_name  = bundle.Name;
     this._total_percent = percent;
     base.StartCoroutine(this.Download(bundle, url, callback1, callback2));
 }
Ejemplo n.º 2
0
        private IEnumerator Download(XBundleData bundle, string url, HandleBundleDownload callback1, HandleFetchBundle callback2)
        {
            XSingleton <XTimerMgr> .singleton.KillTimer(this._token);

            this._token = XSingleton <XTimerMgr> .singleton.SetTimer(0.1f, this._progressCb, null);

            this._downloader = new WWW(url);
            yield return(this._downloader);

            XSingleton <XTimerMgr> .singleton.KillTimer(this._token);

            this.Progress(null);
            XSingleton <XTimerMgr> .singleton.KillTimer(this._token);

            bool flag = false;

            if (callback1 != null)
            {
                AsyncWriteRequest asyncWriteRequest = callback1(this._downloader, bundle, this._downloader.error);
                while (!asyncWriteRequest.IsDone)
                {
                    if (asyncWriteRequest.HasError)
                    {
                        flag = true;
                        break;
                    }
                    yield return(null);
                }
                XSingleton <XUpdater> .singleton.XPlatform.SetNoBackupFlag(asyncWriteRequest.Location);
            }
            if (flag)
            {
                this._log.Length = 0;
                this._log.AppendFormat(XSingleton <XStringTable> .singleton.GetString("XUPDATE_ERROR_DOWNLOADRESFAILED"), bundle.Name);
                XSingleton <XLoadingUI> .singleton.SetStatus(this._log.ToString(), 255, 255, 255);
            }
            else if (callback2 != null)
            {
                callback2(this._downloader, this._downloader.bytes, bundle, this._download);
            }
            this._downloader = null;
            yield break;
        }