private static void OnTaskCompleted <T>(TaskCompletionSource <T> tcs, UnityWebRequest request) where T : class { try { #if UNITY_5 if (request.isError) #else if (request.isHttpError || request.isNetworkError) #endif { tcs.TrySetException(new WebRequestException(request.error, request.responseCode)); } else if (request.downloadHandler != null) { var result = AsyncWww.GetResult <T>(request); tcs.TrySetResult(result); } else { tcs.TrySetResult(null); } } catch (Exception e) { tcs.TrySetException(e); } }
private static void OnTaskCompleted <T>(TaskCompletionSource <T> tcs, WWW www) where T : class { try { if (string.IsNullOrEmpty(www.error)) { var result = AsyncWww.GetResult <T>(www); tcs.TrySetResult(result); } else { tcs.TrySetException(new WebRequestException(www.error)); } } catch (Exception e) { tcs.TrySetException(e); } }
/// <summary> /// Initializes the operation result value. Called when the underlying <see cref="UnityWebRequest"/> has completed withou errors. /// </summary> protected virtual T GetResult(UnityWebRequest request) { return(AsyncWww.GetResult <T>(request)); }
/// <summary> /// Initializes the operation result value. Called when the underlying <see cref="WWW"/> has completed withou errors. /// </summary> protected virtual T GetResult(WWW request) { return(AsyncWww.GetResult <T>(request)); }