private void Update() { if (m_WWW == null) { return; } int deltaLength = m_WWW.bytesDownloaded - m_LastDownloadedSize; if (deltaLength > 0) { m_LastDownloadedSize = m_WWW.bytesDownloaded; DownloadAgentHelperUpdateLengthEventArgs downloadAgentHelperUpdateLengthEventArgs = DownloadAgentHelperUpdateLengthEventArgs.Create(deltaLength); m_DownloadAgentHelperUpdateLengthEventHandler(this, downloadAgentHelperUpdateLengthEventArgs); ReferencePool.Release(downloadAgentHelperUpdateLengthEventArgs); } if (m_WWW == null) { return; } if (!m_WWW.isDone) { return; } if (!string.IsNullOrEmpty(m_WWW.error)) { DownloadAgentHelperErrorEventArgs dodwnloadAgentHelperErrorEventArgs = DownloadAgentHelperErrorEventArgs.Create(m_WWW.error.StartsWith(RangeNotSatisfiableErrorCode.ToString()), m_WWW.error); m_DownloadAgentHelperErrorEventHandler(this, dodwnloadAgentHelperErrorEventArgs); ReferencePool.Release(dodwnloadAgentHelperErrorEventArgs); } else { byte[] bytes = m_WWW.bytes; DownloadAgentHelperUpdateBytesEventArgs downloadAgentHelperUpdateBytesEventArgs = DownloadAgentHelperUpdateBytesEventArgs.Create(bytes, 0, bytes.Length); m_DownloadAgentHelperUpdateBytesEventHandler(this, downloadAgentHelperUpdateBytesEventArgs); ReferencePool.Release(downloadAgentHelperUpdateBytesEventArgs); DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = DownloadAgentHelperCompleteEventArgs.Create(bytes.Length); m_DownloadAgentHelperCompleteEventHandler(this, downloadAgentHelperCompleteEventArgs); ReferencePool.Release(downloadAgentHelperCompleteEventArgs); } }
private void Update() { if (m_UnityWebRequest == null) { return; } if (!m_UnityWebRequest.isDone) { return; } bool isError = false; #if UNITY_2020_2_OR_NEWER isError = m_UnityWebRequest.result != UnityWebRequest.Result.Success; #elif UNITY_2017_1_OR_NEWER isError = m_UnityWebRequest.isNetworkError || m_UnityWebRequest.isHttpError; #else isError = m_UnityWebRequest.isError; #endif if (isError) { DownloadAgentHelperErrorEventArgs downloadAgentHelperErrorEventArgs = DownloadAgentHelperErrorEventArgs.Create(m_UnityWebRequest.responseCode == RangeNotSatisfiableErrorCode, m_UnityWebRequest.error); m_DownloadAgentHelperErrorEventHandler(this, downloadAgentHelperErrorEventArgs); ReferencePool.Release(downloadAgentHelperErrorEventArgs); } else { DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = DownloadAgentHelperCompleteEventArgs.Create((long)m_UnityWebRequest.downloadedBytes); m_DownloadAgentHelperCompleteEventHandler(this, downloadAgentHelperCompleteEventArgs); ReferencePool.Release(downloadAgentHelperCompleteEventArgs); } }
public override void Update() { if (m_UnityWebRequest == null) { return; } if (!m_UnityWebRequest.isDone) { return; } bool isError = false; isError = m_UnityWebRequest.isNetworkError || m_UnityWebRequest.isHttpError; if (isError) { DownloadAgentHelperErrorEventArgs downloadAgentHelperErrorEventArgs = DownloadAgentHelperErrorEventArgs.Create(m_UnityWebRequest.responseCode == RangeNotSatisfiableErrorCode, m_UnityWebRequest.error); m_DownloadAgentHelperErrorEventHandler(this, downloadAgentHelperErrorEventArgs); ReferencePool.Release(downloadAgentHelperErrorEventArgs); } else { DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = DownloadAgentHelperCompleteEventArgs.Create((int)m_UnityWebRequest.downloadedBytes); m_DownloadAgentHelperCompleteEventHandler(this, downloadAgentHelperCompleteEventArgs); ReferencePool.Release(downloadAgentHelperCompleteEventArgs); } }
private void Update() { if (m_UnityWebRequest == null) { return; } if (!m_UnityWebRequest.isDone) { return; } bool isError = false; #if UNITY_2017_1_OR_NEWER isError = m_UnityWebRequest.isNetworkError || m_UnityWebRequest.isHttpError; #else isError = m_UnityWebRequest.isError; #endif if (isError) { DownloadAgentHelperErrorEventArgs downloadAgentHelperErrorEventArgs = DownloadAgentHelperErrorEventArgs.Create(false, ""); m_DownloadAgentHelperErrorEventHandler(this, downloadAgentHelperErrorEventArgs); ReferencePool.Release(downloadAgentHelperErrorEventArgs); } else { DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = DownloadAgentHelperCompleteEventArgs.Create((int)m_UnityWebRequest.downloadedBytes); m_DownloadAgentHelperCompleteEventHandler(this, downloadAgentHelperCompleteEventArgs); ReferencePool.Release(downloadAgentHelperCompleteEventArgs); } }