Learn how UniTask can turn your long running operations into an allocation free workflow, completely replacing Coroutines, Asynchronous Tasks and even Unity's new Awaitable class. The feature rich UniTask library can seem overwhelming at first glace, but getting started is easier than you think! With the help of UniTask's extension methods you can convert your entire workflow with minimal effort and start using this efficient allocation free async/await integration for Unity right now.
https://github.com/Cysharp/UniTask
IMPORTANT NOTES:
1) When calling a UniTask, it is preferred to use async UniTaskVoid over using async void in the calling method's signature.
2) Starting from Unity 2022.2, the MonoBehaviour class includes a destroyCancellationToken so you don't need to use the extension method GetCancellationTokenOnDestroy()
3) If you need to await the same UniTask multiple times, use UniTask.Lazy() to manage continuations.
4) There is a known issue with UniTask.WhenAll where it exits early if any task throws an exception, which differs from the expected behavior of waiting for all tasks to complete before handling exceptions. One solution is to use a helper method WhenAllSettled, allowing all tasks to finish, providing a detailed result for each task, including any exceptions.
Issue: https://github.com/Cysharp/UniTask/is...
Potential Solution: https://gist.github.com/adammyhre/40e...
Want to support me? 😀
Buy me a coffee! https://ko-fi.com/adammyhre
🔔 Subscribe for more Unity Tutorials / @git-amend
Discord: / discord
#unity3d #gamedev #indiedev
▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 Coroutines
6:00 Tasks
9:10 Cancellation Tokens
11:54 UniTask
18:10 Async LINQ
21:00 Generic UniTask
22:08 Awaitable
More Useful Code:
https://github.com/adammyhre?tab=repo...
Unity Utility Library: https://github.com/adammyhre/Unity-Utils
Lock Inspector Hotkey: https://gist.github.com/adammyhre/475...
Assets Shown In This Video (Affiliate Links)
Stylized Nature MegaKit https://quaternius.itch.io/stylized-n...
Procedural Circular Health and Progress Bars Pro: https://assetstore.unity.com/packages...
Hot Reload: https://assetstore.unity.com/packages...
Hierarchy Icons: https://assetstore.unity.com/packages...
Better Transform: https://assetstore.unity.com/packages...
Better Mesh Filter: https://assetstore.unity.com/packages...
Editor Console Pro: https://assetstore.unity.com/packages...
Any Object Finder: https://assetstore.unity.com/packages...
Follow me!
https://linktr.ee/gitamend
Watch video UniTask: How It Replaces Coroutines, Tasks and Awaitable online without registration, duration hours minute second in high quality. This video was added by user git-amend 25 August 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 12,99 once and liked it 83 people.