Asynchronously load large/complex game objects using Coroutines...

Not sure I totally understand “yield return null”

I’m trying to asynchronously load a large and frustratingly complex game object by dividing the loading up into different frames.

So I’m basically trying to cut up all the various functions that get called in the awake() function and start() functions into different frames.

so right now awake() looks like

"private void awake() {

StartCoroutine(awaken_thing1());

StartCoroutine(awaken_thing2());

}

etc…

and in each IEnumerator awaken_thingX, it starts with yield return null. Which I thought would make them all run one frame after another, but instead it seems like it’s just pushing the full awake() / start() function until the end of the first frame and it’s just all going in one frame, just getting computed at the end. Frustrating.

Any idea how to do what I want to do here?

You can get a certain distance with coroutines, but they do reach a limit, especially as EVERYTHING runs in the same thread. This timing diagram may give you insight into how to accomplish what you want, as well as why you’re seeing the behavior you are seeing:

Here is some timing diagram help:

You could also look at Unity’s Addressables system, which is designed to provide asynchronous loading.