diff --git a/README.md b/README.md index 55db857..3d56794 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,8 @@ Provides an efficient allocation free async/await integration to Unity. * Highly compatible behaviour with Task/ValueTask/IValueTaskSource Techinical details, see blog post: [UniTask v2 — Zero Allocation async/await for Unity, with Asynchronous LINQ -](https://medium.com/@neuecc/unitask-v2-zero-allocation-async-await-for-unity-with-asynchronous-linq-1aa9c96aa7dd) +](https://medium.com/@neuecc/unitask-v2-zero-allocation-async-await-for-unity-with-asynchronous-linq-1aa9c96aa7dd) +Advanced tips, see blog post: [Extends UnityWebRequest via async decorator pattern — Advanced Techniques of UniTask](https://medium.com/@neuecc/extends-unitywebrequest-via-async-decorator-pattern-advanced-techniques-of-unitask-ceff9c5ee846) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs index 2acb110..8664f03 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskExtensions.cs @@ -732,7 +732,7 @@ namespace Cysharp.Threading.Tasks return await await task; } - public static async UniTask Unwrap(this UniTask task) + public static async UniTask Unwrap(this UniTask task) { await await task; } @@ -741,22 +741,42 @@ namespace Cysharp.Threading.Tasks { return await await task; } + + public static async UniTask Unwrap(this Task> task, bool continueOnCapturedContext) + { + return await await task.ConfigureAwait(continueOnCapturedContext); + } - public static async UniTask Unwrap(this Task task) + public static async UniTask Unwrap(this Task task) { await await task; } + + public static async UniTask Unwrap(this Task task, bool continueOnCapturedContext) + { + await await task.ConfigureAwait(continueOnCapturedContext); + } public static async UniTask Unwrap(this UniTask> task) { return await await task; } + + public static async UniTask Unwrap(this UniTask> task, bool continueOnCapturedContext) + { + return await (await task).ConfigureAwait(continueOnCapturedContext); + } - public static async UniTask Unwrap(this UniTask task) + public static async UniTask Unwrap(this UniTask task) { await await task; } + public static async UniTask Unwrap(this UniTask task, bool continueOnCapturedContext) + { + await (await task).ConfigureAwait(continueOnCapturedContext); + } + #if UNITY_2018_3_OR_NEWER sealed class ToCoroutineEnumerator : IEnumerator diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs index 3a19a47..9ff4ffa 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.AssetBundleRequestAllAssets.cs @@ -46,6 +46,11 @@ namespace Cysharp.Threading.Tasks this.continuationAction = null; } + public AssetBundleRequestAllAssetsAwaiter GetAwaiter() + { + return this; + } + public bool IsCompleted => asyncOperation.isDone; public UnityEngine.Object[] GetResult()