Exemplo n.º 1
0
        private void StartTask(string url, string saveFile, AssetBundleConfig config, HttpDownloadCallback finishCallback)
        {
            lock (mLockObject)
            {
                mUrl            = url;
                mSaveFile       = saveFile;
                mConfig         = config;
                mFinishCallback = finishCallback;
                mDownloadedSize = 0;

                mHasTask = true;
            }
        }
Exemplo n.º 2
0
        private void Download()
        {
            if (!mIsPause && mDownloadTask.Count > 0 && !mIsDownload)
            {
                if (null == mDownloader || (!mDownloader.IsProcess() && !mDownloader.HasTask()))
                {
                    mCurTask = mDownloadTask[mDownloadTask.Count - 1];
                    HttpDownloadCallback callback = (success) =>
                    {
                        lock (mLockObject)
                        {
                            DownloadCallback(success, mCurTask);
                        }
                    };
                    mDownloader = HttpDownload.StartDownloadFile(mCurTask.url, mCurTask.saveFile, mCurTask.config, callback);
                    mDownloadTask.RemoveAt(mDownloadTask.Count - 1);
                    mIsDownload = true;

                    LogMgr.UnityLog("http download:" + mCurTask.url);
                }
            }
        }
Exemplo n.º 3
0
        public static HttpDownload StartDownloadFile(string url, string saveFile, AssetBundleConfig config, HttpDownloadCallback finishCallback = null)
        {
            if (null == downloader)
            {
                downloader = new HttpDownload();
            }

            downloader.StartTask(url, saveFile, config, finishCallback);

            return(downloader);
        }