Fix UnityWebRequestExtensions obsolete warning in Unity 2020.2

master
neuecc 2020-06-19 16:46:30 +09:00
parent c2538da1cd
commit 3980f314fa
5 changed files with 44 additions and 8 deletions

View File

@ -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;

View File

@ -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
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 111ba0e639de1d7428af6c823ead4918
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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));
}

View File

@ -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));
}