You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implementing concurrency in Unity has been a major pain because
async/await with Task of C# is good to write and read, but tricky to use because most of Unity API is only allowed on the main thread, such that one has to take care which thread is currently executing the code
the programming model with Unity's Coroutines is cumbersome (e.g. no method return values) and still executed on the main thread. So it does not provide a way to execute run long running tasks in the background (e.g. vocals isolation).
Due to these challenges, Reactive Programming via UniRx seemed a good alternative as it provides:
easy way to switch from background thread to main thread and vice versa
However, working with UniRx has also been hard to write and maintain. For example, it has quite some learning curve, sometimes tricky semantics, is annoying to debug, and the syntax is not as smooth as async/await.
Suggested solution/s
By now, Unity supports a custom implementation of async/await via Awaitable (instead of a C# Task).
This seems to overcome the drawbacks of the previous approaches as it pairs the smooth syntax of async/await with good integration of Unity's API. Plus, it is easy to switch between background and main thread.
Your opinion on the topic
Prefer async/await with Awaitable in Unity over Coroutines and UniRx.
Consider to refactor some usage of Coroutines and UniRx to instead use async/await with Awaitable
Probably, AI tools can help with the refactoring (GitHub Copilot, JetBrains AI, ChatGPT, etc., choose your favorite)
Some concurrent code has grows really ugly and could use some love. Finally, Unity provides some tools that could make this fun again.
The text was updated successfully, but these errors were encountered:
Problem or question to be solved
Implementing concurrency in Unity has been a major pain because
Due to these challenges, Reactive Programming via UniRx seemed a good alternative as it provides:
However, working with UniRx has also been hard to write and maintain. For example, it has quite some learning curve, sometimes tricky semantics, is annoying to debug, and the syntax is not as smooth as async/await.
Suggested solution/s
By now, Unity supports a custom implementation of async/await via Awaitable (instead of a C# Task).
This seems to overcome the drawbacks of the previous approaches as it pairs the smooth syntax of async/await with good integration of Unity's API. Plus, it is easy to switch between background and main thread.
Your opinion on the topic
The text was updated successfully, but these errors were encountered: