Fix UnityWebRequestExtensions obsolete warning in Unity 2020.2
parent
c2538da1cd
commit
3980f314fa
|
@ -36,6 +36,7 @@
|
|||
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\DiagnosticsExtensions.cs;
|
||||
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\PlayerLoopRunner.cs;
|
||||
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\ContinuationQueue.cs;
|
||||
..\UniTask\Assets\Plugins\UniTask\Runtime\Internal\UnityWebRequestExtensions.cs;
|
||||
|
||||
..\UniTask\Assets\Plugins\UniTask\Runtime\CancellationTokenSourceExtensions.cs;
|
||||
..\UniTask\Assets\Plugins\UniTask\Runtime\EnumeratorAsyncExtensions.cs;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace Cysharp.Threading.Tasks.Internal
|
||||
{
|
||||
internal static class UnityWebRequestResultExtensions
|
||||
{
|
||||
public static bool IsError(this UnityWebRequest unityWebRequest)
|
||||
{
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
var result = unityWebRequest.result;
|
||||
return (result == UnityWebRequest.Result.ConnectionError)
|
||||
|| (result == UnityWebRequest.Result.DataProcessingError)
|
||||
|| (result == UnityWebRequest.Result.ProtocolError);
|
||||
#else
|
||||
return unityWebRequest.isHttpError || unityWebRequest.isNetworkError;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 111ba0e639de1d7428af6c823ead4918
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1221,7 +1221,7 @@ namespace Cysharp.Threading.Tasks
|
|||
continuationAction = null;
|
||||
var result = asyncOperation.webRequest;
|
||||
asyncOperation = null;
|
||||
if (result.isHttpError || result.isNetworkError)
|
||||
if (result.IsError())
|
||||
{
|
||||
throw new UnityWebRequestException(result);
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ namespace Cysharp.Threading.Tasks
|
|||
{
|
||||
var result = asyncOperation.webRequest;
|
||||
asyncOperation = null;
|
||||
if (result.isHttpError || result.isNetworkError)
|
||||
if (result.IsError())
|
||||
{
|
||||
throw new UnityWebRequestException(result);
|
||||
}
|
||||
|
@ -1312,7 +1312,7 @@ namespace Cysharp.Threading.Tasks
|
|||
{
|
||||
completed = true;
|
||||
var result = asyncOperation.webRequest;
|
||||
if (result.isHttpError || result.isNetworkError)
|
||||
if (result.IsError())
|
||||
{
|
||||
core.TrySetException(new UnityWebRequestException(result));
|
||||
}
|
||||
|
@ -1470,7 +1470,7 @@ namespace Cysharp.Threading.Tasks
|
|||
|
||||
if (asyncOperation.isDone)
|
||||
{
|
||||
if (asyncOperation.webRequest.isHttpError || asyncOperation.webRequest.isNetworkError)
|
||||
if (asyncOperation.webRequest.IsError())
|
||||
{
|
||||
core.TrySetException(new UnityWebRequestException(asyncOperation.webRequest));
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace Cysharp.Threading.Tasks
|
|||
var result = <#= $"asyncOperation.{t.returnField}" #>;
|
||||
asyncOperation = null;
|
||||
<# if(t.returnType == "UnityWebRequest") { #>
|
||||
if (result.isHttpError || result.isNetworkError)
|
||||
if (result.IsError())
|
||||
{
|
||||
throw new UnityWebRequestException(result);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ namespace Cysharp.Threading.Tasks
|
|||
var result = <#= $"asyncOperation.{t.returnField}" #>;
|
||||
asyncOperation = null;
|
||||
<# if(t.returnType == "UnityWebRequest") { #>
|
||||
if (result.isHttpError || result.isNetworkError)
|
||||
if (result.IsError())
|
||||
{
|
||||
throw new UnityWebRequestException(result);
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ namespace Cysharp.Threading.Tasks
|
|||
completed = true;
|
||||
<# if(t.returnType == "UnityWebRequest") { #>
|
||||
var result = asyncOperation.webRequest;
|
||||
if (result.isHttpError || result.isNetworkError)
|
||||
if (result.IsError())
|
||||
{
|
||||
core.TrySetException(new UnityWebRequestException(result));
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ namespace Cysharp.Threading.Tasks
|
|||
if (asyncOperation.isDone)
|
||||
{
|
||||
<# if(t.returnType == "UnityWebRequest") { #>
|
||||
if (asyncOperation.webRequest.isHttpError || asyncOperation.webRequest.isNetworkError)
|
||||
if (asyncOperation.webRequest.IsError())
|
||||
{
|
||||
core.TrySetException(new UnityWebRequestException(asyncOperation.webRequest));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue