Async task utility package for Unity
Helper methods for starting tasks on the Unity thread.
Start and await coroutines from any thread.
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
{
"dependencies": {
"com.gameframe.async": "https://github.com/coryleach/UnityAsync.git#1.0.3",
...
},
}
//Start a coroutine from anywhere without a monobehaviour
//Your coroutine will run on the main thread
var task = CoroutineRunner.RunAsync(MyCoroutine());
//You can await the returned task which will complete when the coroutine is done
await task;
//This will execute MyMethod on the main Unity thread
var task = UnityTaskUtil.RunOnUnityThreadAsync(MyMethod);
//A task is returned that you can await
await task;
// Currently on main thread
await Awaiters.BackgroundThread;
//You should now be on a background thread
//Await one frame
await Awaiters.NextFrame;
//Currently on a background thread
await Awaiters.MainUnityThread;
//Task is now running on the Unity main thread
👤 Cory Leach
- Twitter: @coryleach
- Github: @coryleach
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator