Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Difference between single thread/Player loop and ThreadPool? #441

Unanswered
bowtox asked this question in Q&A
Discussion options

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!

You must be logged in to vote

Replies: 1 comment

Comment options

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.)

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /