Intro to Coroutines in Unity (C#)


In this demonstration, we'll be going over how Coroutines operate in Unity and how we can effectively use them in an application.



To understand how coroutines operate in Unity, it is essential to understand the concept of concurrency.

In the simplest form, concurrency is when two parts of a program operate at the same interval, but not at the same time. As an example, Unity runs Update() and LateUpdate() every frame draw. Although they both run at the same interval (every frame), LateUpdate always runs after Update during every frame.

Example Application

The following example showcases a component that reads user input without using Unity's Update method.

Additional information on how coroutines work with Unity can be found on Unity's official page for coroutines: