Skip to content

Instantly share code, notes, and snippets.

@andywatts
Created June 17, 2020 23:58
Show Gist options
  • Save andywatts/d49dfa758b43a7e821bad16d6af01373 to your computer and use it in GitHub Desktop.
Save andywatts/d49dfa758b43a7e821bad16d6af01373 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.Networking;
using Cysharp.Threading.Tasks;
public class TestUniTask : MonoBehaviour
{
async void Start()
{
Debug.Log("UniTaskTest start");
// var playerLoop = Unity.Entities.ScriptBehaviourUpdateOrder.CurrentPlayerLoop();
// PlayerLoopHelper.Initialize(ref playerLoop);
// var playerLoop = UnityEngine.LowLevel.PlayerLoop.GetCurrentPlayerLoop();
// PlayerLoopHelper.Initialize(ref playerLoop);
Debug.Log("UniTaskTest reinitialization complete");
UniTask<int> t1 = Chunks(1);
UniTask<int> t2 = Chunks(2);
UniTask<int> t3 = Chunks(3);
var (o1, o2, o3) = await UniTask.WhenAll(t1, t2, t3);
Debug.Log("UniTaskTest stop");
}
async UniTask<int> Chunks(int i)
{
await UniTask.DelayFrame(100);
await Blocks();
Debug.Log($"Chunks loaded {i}");
return i;
}
async UniTask<string> Blocks()
{
await UniTask.DelayFrame(100);
Debug.Log($"Blocks loaded");
return "abc";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment