Esempio n. 1
0
    //Note:当下载的文件数据大于2G时,该int类型的参数将会数据溢出,所以先自己通过响应头来获取长度,获取不到再使用参数的方式
    protected override void ReceiveContentLength(int contentLength)
    {
        string contentLengthStr = _unityWebRequest.GetResponseHeader("Content-Length");

        if (contentLengthStr != null && !"".Equals(contentLengthStr))
        {
            try
            {
                _totalFileSize = long.Parse(contentLengthStr);
            }
            catch (System.FormatException e)
            {
                UnityEngine.Debug.LogWarning("获取文件长度失败,contentLengthStr:" + contentLengthStr + "," + e.Message);
                _totalFileSize = contentLength;
            }
            catch (System.Exception e)
            {
                UnityEngine.Debug.LogWarning("获取文件长度失败,contentLengthStr:" + contentLengthStr + "," + e.Message);
                _totalFileSize = contentLength;
            }
        }
        else
        {
            _totalFileSize = contentLength;
        }
        //这里拿到的下载大小是待下载的文件大小,需要加上本地已下载文件的大小才等于总大小
        if (_useRange)
        {
            _totalFileSize += _localFileSize;
        }

        if (_useRange && _fileSize != -1 && _totalFileSize != _fileSize)
        {
            ErrorEvent?.Invoke();
        }
        else
        {
            _lastTime     = UnityEngine.Time.time;
            _lastDataSize = _curFileSize;
            StartDownloadEvent?.Invoke();
        }
    }
Esempio n. 2
0
 public void StartDownload(StartDownloadEvent e, Node any, [JoinAll] DownloadScreenNode screenNode)
 {
     screenNode.textMapping.Text = screenNode.launcherDownloadScreenText.DownloadText;
 }