Unity Async Await - Make Your Game Run Smoother!

preview_player
Показать описание
In this tutorial want to explain the Async Await Unity workflow so that you can run code on a separate thread to make your game run faster. I will also show you how to stop a task using a Cancellation Token as it is a bit more work than running code synchronously using a coroutine.

𝗟𝗲𝗮𝗿𝗻 𝗺𝗼𝗿𝗲 𝗮𝗯𝗼𝘂𝘁 𝗨𝗻𝗶𝘁𝘆 𝗮𝗻𝗱 𝗖# (and support the channel) by checking out my video courses:

𝗛𝗮𝘃𝗲 𝗮𝗻𝘆 𝗾𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝘀? 𝗝𝗼𝗶𝗻 𝘁𝗵𝗲 𝗱𝗶𝘀𝗰𝗼𝗿𝗱!

𝗣𝗟𝗘𝗔𝗦𝗘 support the channel:

00:00 Introduction
00:26 Blocking the main thread
01:04 What is Main thread
03:16 Introducing Task class
04:29 Using Async and await
10:07 How to stop a Task - Cancellation Token

#unitycsharp #unity #sunnyvalleystudio
Рекомендации по теме
Комментарии
Автор

This is honestly a really good tutorial about something that not many people cover. Thanks a lot!

keelanbowker-obrien
Автор

THANKS THANKS THANKS! Superclear and esaustive explanation of an a bit complex argument in an easy way! All teacher should explain like you! Thanks again!

vima
Автор

Amazing tutorial! Can't wait for parallel topic. Thanks!

PROeloGangsta
Автор

I've found you by accident while I was reading a post on reddit, I'm glad because I was just looking for some tutorials about exactly this. And you're video about lambda expression is really good too, I finally understand it better.
Subscribed, I'll check more of your videos and I'm waiting for the next one

mementomori
Автор

Damn, you have such a good visualization, it's ease me too understanding it 👌

Focto
Автор

This video is very good, BUT, deserves an Update with Awaitable class =)

bsdrago
Автор

Two years old video. Still its very useful and i have subscribed to your channel. Looking forward to see many interesting topics!

cryptoversegirl
Автор

Very simple and clear explanation, thanks!

devgame
Автор

this literally saved my game thanks so much

lubba
Автор

This is very well explained, thank you.

melodysprout
Автор

Wow thank you! I think Async can be a great performance booster on many parts. I´m happy to found your channel.

Eculeus
Автор

Thank you once again, neat introduction! These shorter videos are nice, it is hard to invest hours of time into long series... even if topics covered in those series were interesting.

ss
Автор

Thanks a lot man! That is exactly what I was looking for.

vitvohralik
Автор

so far the best entry tutorial about Task in Unity

runyu
Автор

Wow! It looks like Unity's C# now supports the full range of C# 8 functionality! That's a *monumental* improvement over the way it was the last time I used Unity! Way To Go Unity!

By the way, I'm very sure the poster absolutely does not mean to suggest that sweeping incredibly inefficient code under the rug by sticking it in background threads is a great and wonderful approach to resolving performance issues. Please handle async with care! It's very easy to end up loading down all the cores and make your poor user's entire system bog down to a crawl. Operating systems should probably restrict any single app from completely loading down all the cores, but by and large they don't. I'm sure this was just a rough sample to demonstrate async, but please do be aware that the machine still does actually have to run your code, and most of the time you find yourself using a nested loop like that there is probably a much more efficient way to do what you're doing.

shavais
Автор

Awesome Would love to know more on how Task works with out async

efexzium
Автор

Holy Moly, instantly subbed to this gem channel, though which video are you referring to at the end? or isn't it out yet?

RRaiho
Автор

perfect tutorial..probably best explain how to use threads correctly!Thank you.Can you put the gist for this type of tutorials..would be awsome

quadriproduction
Автор

Does this help remove lag when instantiating large objects?

Amazing tutorial btw!

fbot
Автор

This works well, but I am still stuck in my project. I can't call any unity functions without getting an error saying "[function] can only be called from the main thread". However, I need to run Unity methods asynchronously. I need to render a render texture and save it as a sprite. How can I do this without killing performance?

ryan