-
-
Notifications
You must be signed in to change notification settings - Fork 938
-
Hey, I don't understand...
The documentation says:
Most UniTask methods run on a single thread (PlayerLoop), with only UniTask.Run(Task.Run equivalent) and UniTask.SwitchToThreadPool running on a thread pool. If you use a thread pool, it won't work with WebGL and so on.
UniTask.Run is now deprecated. You can use UniTask.RunOnThreadPool instead. And also consider whether you can use UniTask.Create or UniTask.Void.
Beyond the WebGL platform considerations, what difference does it make to run a UniTask on the Unity thread vs on the thread pool?
I though the goal of using UniTask over C# Task was to embrace the single threaded nature of Unity and making the most of it, but this part confuses me.
Can anyone enlightenment me especially on the consequences of not running on the Unity thread?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
You can still run calculations outside of the Unity thread, but certain calls like UI updates won't work because they only run on the Unity thread. I've seen people delegating AI, pathfinding, and generally heavy operations to another thread then return to main thread for further processing (updating UI, gameObject, transforms, etc.)
Beta Was this translation helpful? Give feedback.