I have a bit of a problem with this spaghetti code I’m trying to untangle.
Things fire up left and right and they do so through coroutine and as you know you cannot trace a coroutine.
I’m trying to convert a coroutine that loads a level async into something traceable and my understanding is async await does.
How do I do that?
Here is the original code:
calling method:
public void LoadLevel(string name, bool noWait = false)
{
// ... stuff
StopAllCoroutines();
StartCoroutine(_LoadLevel());
}
IEnumerator _LoadLevel()
{
// ... stuff
StartCoroutine(FadeOutAllAudio());
yield return new WaitForSeconds(1);
yield return LMLoadLevel(loadingName);
}
public AsyncOperation LMLoadLevel(string loadingName)
{
loadLevelAsyncOperation = Application.LoadLevelAsync(loadingName);
Fader.SetAsync(loadLevelAsyncOperation);
return loadLevelAsyncOperation;
}