Multithreading and the C# Job System in Unity
Asynchronous programming is very common when developing .NET projects. But unlike what many people who are familiar with .NET development think, Unity's support for asynchronous programming was not friendly at first.
Coroutines
Before Unity 2017, if a game developer wanted to handle asynchronous operations, a common scenario was waiting for a network response. The ideal solution was to use coroutines in Unity.
We can start a coroutine in Unity as follows:
void Start() { var url = "https://jiadongchen.com"; StartCoroutine(DownloadFile(url)); } private static IEnumerator DownloadFile(string url) { var request = UnityWebRequest.Get(url); ...