Task/UniTask-based
Main Thread dispatcher classes, no GameObject
s involved.
- Simple to use: call
MainThreadTask.Run
and that's it, your action will run on the Main Thread! async
methodMainThreadTask.RunAsync
, so you canawait
for execution to complete- TaskScheduler and TaskFactory used for running Tasks on the Main Thread are available
- UniTask-based implementation in
MainThreadUniTask
class, conditionally compiled if UniTask is detected in project System.Action
extension methodsInvokeOnMainThread
andInvokeOnMainThreadAsync
- No
GameObject
s involved - Simple implementations with around 50 lines of code each
Either:
- Install via Unity Package Manager using the following URL:
https://github.com/gilzoide/unity-main-thread-task.git#1.0.0
-
Copy the implementation file Runtime/MainThreadTask.cs and/or Runtime/MainThreadUniTask.cs to your project.
If using UniTask, either remove the
#if/#endif
lines fromMainThreadUniTask.cs
or defineHAVE_UNITASK
in your project's scripting define symbols.