UnityWebRequestExtensions.cs 840 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine.Networking;
  7. namespace Cysharp.Threading.Tasks.Internal
  8. {
  9. #if ENABLE_UNITYWEBREQUEST && (!UNITY_2019_1_OR_NEWER || UNITASK_WEBREQUEST_SUPPORT)
  10. internal static class UnityWebRequestResultExtensions
  11. {
  12. public static bool IsError(this UnityWebRequest unityWebRequest)
  13. {
  14. #if UNITY_2020_2_OR_NEWER
  15. var result = unityWebRequest.result;
  16. return (result == UnityWebRequest.Result.ConnectionError)
  17. || (result == UnityWebRequest.Result.DataProcessingError)
  18. || (result == UnityWebRequest.Result.ProtocolError);
  19. #else
  20. return unityWebRequest.isHttpError || unityWebRequest.isNetworkError;
  21. #endif
  22. }
  23. }
  24. #endif
  25. }