mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-23 16:20:21 +00:00
@@ -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");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user