protected override void OnTimeOut(Transaction transaction) { HTTPRequest request = (HTTPRequest)transaction.request; if (!string.IsNullOrEmpty(request.transactionId)) { if (request.tries > 1 && transaction.tries < request.tries - 1) { this.RestartTransaction(transaction); return; } if (request.onTimeOut != null) { request.onTimeOut(transaction.id); return; } if (request.onError != null) { request.onError("timeout", transaction.id); return; } if (this._onErrorCallback != null) { this._onErrorCallback("timeout", transaction.id); return; } throw new UnityEngine.UnityException("Transaction [" + transaction.id + "] time out, but no callbacks for it"); } else { throw new UnityEngine.UnityException("Transaction [" + transaction.id + "] time out, but [request] is null"); } } // OnTimeOut
} // RunGetAssetBundleCoroutine private IEnumerator DoCallback(WWW www, HTTPRequest request) { if (string.IsNullOrEmpty(www.error)) { this.SetTransactionStatus(request.transactionId, transactionStatus.completed); if (request.wwwCallback != null) { request.wwwCallback(www, request.transactionId); } #if UNITY_PRO_LICENSE && !UNITY_WEBGL else if (request.assetBundleCallback != null) { request.assetBundleCallback(www.assetBundle, request.transactionId); } else if (request.movieTextureCallback != null) { MovieTexture movieTexture = www.movie; while (!movieTexture.isReadyToPlay) { yield return(null); } request.movieTextureCallback(movieTexture, request.transactionId); } #endif else if (request.audioClipCallback != null) { request.audioClipCallback(www.audioClip, request.transactionId); } else if (request.textureCallback != null) { request.textureCallback(www.texture, request.transactionId); } else if (request.textureNonReadableCallback != null) { request.textureNonReadableCallback(www.textureNonReadable, request.transactionId); } else if (request.stringCallback != null) { request.stringCallback(www.text, request.transactionId); } else if (request.bytesCallback != null) { request.bytesCallback(www.bytes, request.transactionId); } this.RemoveTransaction(request.transactionId); } else { this.SetTransactionStatus(request.transactionId, transactionStatus.error); if (request.onError != null) { request.onError(www.error, request.transactionId); } this.RemoveTransaction(request.transactionId); } yield break; } // DoCallback
private IEnumerator DoCallBack(WWW www, HTTPRequest request) { if (string.IsNullOrEmpty(www.error)) { if (request.wwwCallback != null) { request.wwwCallback(www, request.transactionId); } #if UNITY_PRO_LICENSE else if (request.assetBundleCallback != null) { request.assetBundleCallback(www.assetBundle, request.transactionId); } else if (request.movieTextureCallback != null) { MovieTexture movieTexture = www.movie; while (!movieTexture.isReadyToPlay) { yield return null; } request.movieTextureCallback(movieTexture, request.transactionId); } #endif else if (request.audioClipCallback != null) { request.audioClipCallback(www.audioClip, request.transactionId); } else if (request.textureCallback != null) { request.textureCallback(www.texture, request.transactionId); } else if (request.textureNonReadableCallback != null) { request.textureNonReadableCallback(www.textureNonReadable, request.transactionId); } else if (request.stringCallback != null) { request.stringCallback(www.text, request.transactionId); } else if (request.bytesCallback != null) { request.bytesCallback(www.bytes, request.transactionId); } this.RemoveTransaction(request.transactionId); } else { if (request.onError != null) { request.onError(www.error, request.transactionId); } this.RemoveTransaction(request.transactionId); } yield break; }