Add ObjectIdForDebugger to allow IDE stepin debug, #66, #41

pull/75/head
neuecc 2020-04-26 21:49:07 +09:00
parent 341953b441
commit 9f7b897837
3 changed files with 88 additions and 6 deletions

View File

@ -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<int> 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");
}
}

View File

@ -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
}
}

View File

@ -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
}
}