コード例 #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));
 }
コード例 #2
0
        private AsyncWriteRequest OnBundleDownload(WWW www, XBundleData bundle, string error)
        {
            AsyncWriteRequest req = new AsyncWriteRequest();

            if (string.IsNullOrEmpty(error))
            {
                byte[] bs = www.bytes;
                new Thread(delegate
                {
                    req.Location = this.GetLocalPath(bundle);
                    try
                    {
                        File.WriteAllBytes(req.Location, bs);
                        req.IsDone = true;
                    }
                    catch (Exception ex)
                    {
                        this.OnDownloadFailed(ex.Message, req);
                    }
                }).Start();
            }
            else
            {
                this.OnDownloadFailed(error, req);
            }
            return(req);
        }
コード例 #3
0
 internal bool Extract(XBundleData bundle, HandleFetchBundle callback, float percent)
 {
     if (Application.platform != RuntimePlatform.IPhonePlayer)
     {
         this._down_loader.GetBundle(bundle, this.GetLocalUrl(bundle), null, callback, percent);
         return(true);
     }
     if (this._aer == null)
     {
         this._aer = new AsyncExtractRequest();
         new Thread(delegate
         {
             string localPath = this.GetLocalPath(bundle);
             this._aer.Data   = File.ReadAllBytes(localPath);
             this._aer.IsDone = true;
         }).Start();
     }
     if (this._aer.IsDone)
     {
         callback(null, this._aer.Data, bundle, false);
         this._aer.Data = null;
         this._aer      = null;
         return(true);
     }
     return(false);
 }
コード例 #4
0
        internal AsyncCachedRequest IsBundleCached(XBundleData bundle, uint size)
        {
            string             fullpath = this.GetLocalPath(bundle);
            AsyncCachedRequest req      = new AsyncCachedRequest();

            if (bundle.Size < size)
            {
                new Thread(delegate
                {
                    if (File.Exists(fullpath))
                    {
                        byte[] bundle2  = this.LoadFile(fullpath);
                        string a        = this.CalculateMD5(bundle2);
                        req.Cached      = (a == bundle.MD5);
                        req.MaybeCached = true;
                    }
                    req.IsDone = true;
                }).Start();
            }
            else
            {
                req.MaybeCached = File.Exists(fullpath);
                req.IsDone      = true;
            }
            return(req);
        }
コード例 #5
0
        internal string GetLocalUrl(XBundleData data)
        {
            string arg;

            if (XSingleton <XUpdater> .singleton.RunTimePlatform == BuildTarget.Standalone)
            {
                arg = "file:///";
            }
            else
            {
                arg = "file://";
            }
            string text = string.Format("{0}{1}{2}.assetbundle", arg, this._update_path, data.Name);

            XSingleton <XDebug> .singleton.AddLog("LocalURL: ", text, null, null, null, null, XDebugColor.XDebug_None);

            return(text);
        }
コード例 #6
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;
        }
コード例 #7
0
 internal string GetDownloadUrl(XBundleData data)
 {
     return(this.MakeToken(string.Format("{0}{1}/{2}.assetbundle", this.HostUrl, XSingleton <XUpdater> .singleton.Platform, data.Name)));
 }
コード例 #8
0
 internal string GetLocalPath(XBundleData data)
 {
     return(string.Format("{0}{1}.assetbundle", this._update_path, data.Name));
 }
コード例 #9
0
 internal void Download(XBundleData bundle, HandleFetchBundle callback, float percent)
 {
     this._down_loader.GetBundle(bundle, this.GetDownloadUrl(bundle), new HandleBundleDownload(this.OnBundleDownload), callback, percent);
 }