diff --git a/Assets/Scenes/SandboxMain.cs b/Assets/Scenes/SandboxMain.cs index 1faf82d..0354ea9 100644 --- a/Assets/Scenes/SandboxMain.cs +++ b/Assets/Scenes/SandboxMain.cs @@ -14,13 +14,47 @@ public class SandboxMain : MonoBehaviour public Button cancelButton; CancellationTokenSource cts; - async void Start() + void Start() { - UnityEngine.Debug.Log("DOWNLOAD START:" + Time.frameCount); - - var req = await UnityWebRequest.Get(Path.Combine(Application.streamingAssetsPath, "test.txt")).SendWebRequest(); - - UnityEngine.Debug.Log("DOWNLOAD RESULT:" + Time.frameCount + ", " + req.downloadHandler.text); + okButton.onClick.AddListener(() => + { + FooAsync().Forget(); + }); + cancelButton.onClick.AddListener(() => + { + BarAsync().Forget(); + }); } + + async UniTask FooAsync() + { + // use F10, will crash. + var loop = int.Parse("9"); + await UniTask.DelayFrame(loop); + + Debug.Log("OK"); + await UniTask.DelayFrame(loop); + + Debug.Log("Again"); + + return 10; + } + + async UniTaskVoid BarAsync() + { + var loop = int.Parse("10"); + + + var foo = await UniTask.FromResult(100); + + Debug.Log("OK"); + + + Debug.Log("Again"); + + + } + + } diff --git a/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs b/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs index 586f859..76a358d 100644 --- a/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs +++ b/Assets/UniRx.Async/CompilerServices/AsyncUniTaskMethodBuilder.cs @@ -136,6 +136,22 @@ namespace UniRx.Async.CompilerServices public void SetStateMachine(IAsyncStateMachine stateMachine) { } + +#if UNITY_EDITOR + // Important for IDE debugger. + object debuggingId; + private object ObjectIdForDebugger + { + get + { + if (debuggingId == null) + { + debuggingId = new object(); + } + return debuggingId; + } + } +#endif } @@ -268,6 +284,22 @@ namespace UniRx.Async.CompilerServices public void SetStateMachine(IAsyncStateMachine stateMachine) { } + +#if UNITY_EDITOR + // Important for IDE debugger. + object debuggingId; + private object ObjectIdForDebugger + { + get + { + if (debuggingId == null) + { + debuggingId = new object(); + } + return debuggingId; + } + } +#endif } } diff --git a/Assets/UniRx.Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs b/Assets/UniRx.Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs index 2fcd55f..bedf7bf 100644 --- a/Assets/UniRx.Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs +++ b/Assets/UniRx.Async/CompilerServices/AsyncUniTaskVoidMethodBuilder.cs @@ -84,6 +84,22 @@ namespace UniRx.Async.CompilerServices public void SetStateMachine(IAsyncStateMachine stateMachine) { } + +#if UNITY_EDITOR + // Important for IDE debugger. + object debuggingId; + private object ObjectIdForDebugger + { + get + { + if (debuggingId == null) + { + debuggingId = new object(); + } + return debuggingId; + } + } +#endif } }