diff --git a/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityTextureLoader.cs b/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityTextureLoader.cs
index 903a81dd..8fc4698f 100644
--- a/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityTextureLoader.cs
+++ b/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityTextureLoader.cs
@@ -4,34 +4,34 @@
using i5.Toolkit.Core.Utilities.Async;
namespace i5.Toolkit.Core.Utilities.ContentLoaders
-{
- ///
- /// Adapter class which loads textures using Unity's WebRequestsTexture
- ///
- public class UnityTextureLoader : IContentLoader
- {
- ///
- /// Loads the texture at the given URI using Unity's built-in methods
- ///
- /// The uri where the texture is stored
- /// Returns a WebResponse with the results of the web request
- public async Task> LoadAsync(string uri)
- {
- using (UnityWebRequest req = UnityWebRequestTexture.GetTexture(uri))
- {
- await req.SendWebRequest();
-
- if (req.isNetworkError || req.isHttpError)
- {
- i5Debug.LogError("Error fetching texture: " + req.error, this);
- return new WebResponse(req.error, req.responseCode);
- }
- else
- {
- Texture2D texture = DownloadHandlerTexture.GetContent(req);
- return new WebResponse(texture, req.downloadHandler.data, req.responseCode);
- }
- }
- }
- }
+{
+ ///
+ /// Adapter class which loads textures using Unity's WebRequestsTexture
+ ///
+ public class UnityTextureLoader : IContentLoader
+ {
+ ///
+ /// Loads the texture at the given URI using Unity's built-in methods
+ ///
+ /// The uri where the texture is stored
+ /// Returns a WebResponse with the results of the web request
+ public async Task> LoadAsync(string uri)
+ {
+ using (UnityWebRequest req = UnityWebRequestTexture.GetTexture(uri))
+ {
+ await req.SendWebRequest();
+
+ if (req.result == UnityWebRequest.Result.Success)
+ {
+ Texture2D texture = DownloadHandlerTexture.GetContent(req);
+ return new WebResponse(texture, req.downloadHandler.data, req.responseCode);
+ }
+ else
+ {
+ i5Debug.LogError("Error fetching texture: " + req.error, this);
+ return new WebResponse(req.error, req.responseCode);
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityWebRequestLoader.cs b/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityWebRequestLoader.cs
index 43c2ecf3..fa02d434 100644
--- a/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityWebRequestLoader.cs
+++ b/Assets/i5 Toolkit for Unity/Runtime/Experimental/UnityAdapters/ContentLoaders/UnityWebRequestLoader.cs
@@ -21,16 +21,15 @@ public async Task> LoadAsync(string uri)
{
await req.SendWebRequest();
- if (req.result == UnityWebRequest.Result.ConnectionError ||
- req.result == UnityWebRequest.Result.ProtocolError)
+ if (req.result == UnityWebRequest.Result.Success)
{
- i5Debug.LogError("Get request to: " + uri + " returned with error " + req.error, this);
- return new WebResponse(false, req.downloadHandler.text, req.downloadHandler.data, req.responseCode, req.error);
+ return new WebResponse(req.downloadHandler.text, req.downloadHandler.data, req.responseCode);
}
else
{
- return new WebResponse(req.downloadHandler.text, req.downloadHandler.data, req.responseCode);
- }
+ i5Debug.LogError("Get request to: " + uri + " returned with error " + req.error, this);
+ return new WebResponse(false, req.downloadHandler.text, req.downloadHandler.data, req.responseCode, req.error);
+ }
}
}
}
diff --git a/Assets/i5 Toolkit for Unity/Runtime/Utilities/Async/AwaiterExtensions.cs b/Assets/i5 Toolkit for Unity/Runtime/Utilities/Async/AwaiterExtensions.cs
index 1e76678b..b7a2104a 100644
--- a/Assets/i5 Toolkit for Unity/Runtime/Utilities/Async/AwaiterExtensions.cs
+++ b/Assets/i5 Toolkit for Unity/Runtime/Utilities/Async/AwaiterExtensions.cs
@@ -34,48 +34,49 @@
namespace i5.Toolkit.Core.Utilities.Async
{
- ///
- /// We could just add a generic GetAwaiter to YieldInstruction and CustomYieldInstruction
- /// but instead we add specific methods to each derived class to allow for return values
- /// that make the most sense for the specific instruction type.
- ///
- public static class AwaiterExtensions
- {
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitForSeconds instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitForUpdate instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitForEndOfFrame instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitForFixedUpdate instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitForSecondsRealtime instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitUntil instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
- public static SimpleCoroutineAwaiter GetAwaiter(this WaitWhile instruction)
- {
- return GetAwaiterReturnVoid(instruction);
- }
-
+ ///
+ /// We could just add a generic GetAwaiter to YieldInstruction and CustomYieldInstruction
+ /// but instead we add specific methods to each derived class to allow for return values
+ /// that make the most sense for the specific instruction type.
+ ///
+ public static class AwaiterExtensions
+ {
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitForSeconds instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitForUpdate instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitForEndOfFrame instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitForFixedUpdate instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitForSecondsRealtime instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitUntil instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+ public static SimpleCoroutineAwaiter GetAwaiter(this WaitWhile instruction)
+ {
+ return GetAwaiterReturnVoid(instruction);
+ }
+
+#if !UNITY_2023_1_OR_NEWER
public static SimpleCoroutineAwaiter GetAwaiter(this AsyncOperation instruction)
{
return GetAwaiterReturnSelf(instruction);
@@ -104,293 +105,301 @@ public static SimpleCoroutineAwaiter