public override void Run()
        {
            m_request = UnityWebRequest.Get(m_strUrl);
            if (!string.IsNullOrEmpty(m_strPath))
            {
                // 是写到文件的情况开启断点续传
                m_downloadHandler = new DownloaderHandler(m_strPath, OnProgress, OnCompleted);

                m_request.chunkedTransfer = true;
                m_request.disposeDownloadHandlerOnDispose = true;
                m_request.SetRequestHeader("Range", "bytes=" + m_downloadHandler.DownedLength + "-");
                m_request.downloadHandler = m_downloadHandler;
            }

            m_request.Send();
            Debug.LogFormat("Downloader: {0} => {1}", m_strUrl, m_strPath);
        }
Exemple #2
0
        public override void Dispose()
        {
            m_onProgress  = null;
            m_onCompleted = null;
            if (m_request != null)
            {
                if (!m_request.isDone)
                {
                    m_request.Abort();
                }

                m_request.Dispose();
                m_request = null;
            }

            if (m_downloadHandler != null)
            {
                m_downloadHandler.Close();
                m_downloadHandler = null;
            }
        }