diff --git a/src/UniTask/Assets/Editor/EditorRunnerChecker.cs b/src/UniTask/Assets/Editor/EditorRunnerChecker.cs index ebff07c..46372f9 100644 --- a/src/UniTask/Assets/Editor/EditorRunnerChecker.cs +++ b/src/UniTask/Assets/Editor/EditorRunnerChecker.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using UnityEditor; using UnityEngine; +using UnityEngine.Networking; public static class EditorRunnerChecker { @@ -17,11 +18,12 @@ public static class EditorRunnerChecker static async UniTaskVoid RunCore() { - Debug.Log("Start, Wait 5 seconds. deltaTime?" + Time.deltaTime); + Debug.Log("Start"); - await UniTask.Delay(TimeSpan.FromSeconds(5)); + var r = await UnityWebRequest.Get("https://bing.com/").SendWebRequest().ToUniTask(); + Debug.Log(r.downloadHandler.text.Substring(0, 100)); - Debug.Log("End, Wait 5 seconds. deltaTime?" + Time.deltaTime); + Debug.Log("End"); } } diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs index 7252f0c..88dc00d 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs @@ -26,7 +26,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices MoveNextRunner() { - callMoveNext = MoveNext; + callMoveNext = Run; } public static MoveNextRunner Create(ref TStateMachine stateMachine) @@ -38,7 +38,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices [DebuggerHidden] [MethodImpl(MethodImplOptions.AggressiveInlining)] - void MoveNext() + void Run() { stateMachine.MoveNext(); } diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs index db5d27b..05d9339 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs @@ -271,7 +271,7 @@ namespace Cysharp.Threading.Tasks { if (token != version) { - throw new InvalidOperationException("token version is not matched, can not await twice."); + throw new InvalidOperationException("Token version is not matched, can not await twice or get Status after await."); } } } diff --git a/src/UniTask/Assets/Scenes/SandboxMain.cs b/src/UniTask/Assets/Scenes/SandboxMain.cs index 49c6411..5eaef08 100644 --- a/src/UniTask/Assets/Scenes/SandboxMain.cs +++ b/src/UniTask/Assets/Scenes/SandboxMain.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using Unity.Collections; using Unity.Jobs; using UnityEngine; +using UnityEngine.Networking; using UnityEngine.UI; @@ -243,8 +244,39 @@ public class SandboxMain : MonoBehaviour public int MyProperty { get; set; } } + async Task Test1() + { + var r = await TcsAsync("https://bing.com/"); + Debug.Log("TASKASYNC"); + } - void Start() + async UniTaskVoid Test2() + { + var r = await UniAsync("https://bing.com/"); + Debug.Log("UNIASYNC"); + } + + IEnumerator Test3(string url) + { + var req = UnityWebRequest.Get(url).SendWebRequest(); + yield return req; + Debug.Log("COROUTINE"); + } + + static async Task TcsAsync(string url) + { + var req = await UnityWebRequest.Get(url).SendWebRequest(); + return req; + } + + static async UniTask UniAsync(string url) + { + var req = await UnityWebRequest.Get(url).SendWebRequest(); + return req; + } + + + void Start() { //UniTaskAsyncEnumerable.EveryValueChanged(mcc, x => x.MyProperty) // .Do(_ => { }, () => Debug.Log("COMPLETED")) @@ -254,6 +286,9 @@ public class SandboxMain : MonoBehaviour // }) // .Forget(); + _ = Test1(); + Test2().Forget(); + StartCoroutine(Test3("https://bing.com/")); // DG.Tweening.Core.TweenerCore