How to check to see if LoadLevelAdditive finished loading a level?

The problem I have is that I want to see if the level is loaded before I continue.

I don’t want to restart everything when a new section is loaded, but for some reason depending on when things happen the level hasn’t loaded before certain calls are made. For example…

*Call to load level additive

*NPC manager starts putting NPCs on the map and gathering information on objects in the new “level”.

*However, the map hasn’t been loaded yet so the NPC list is not complete and some end up in space or not added at all.

So I need a way to check to see if the level was loaded before the NPC list is created, otherwise the game crashes. I had been using OnLevelWasLoaded() to see if that would happen, but now it won’t fire. So now I’m stuck. How do we check to see if everything was loaded before continuing? It says that Unity Pro has Application.isLoaded, but I don’t have Pro, so what can we do to make sure these errors don’t happen?

Also, I’ve read some things and it’s kind of unreleated, but when I tried to use AsyncOperation.isDone, I kept getting an error CS0120. Of course I later found out that I don’t have Pro, so I can’t use it anyway, but the documentation says it should be there, but it isn’t.

Either way, I just want to solve this problem with my loading of objects and it’s getting frustrating.

I think you were probably using AsyncOperation.isDone incorrectly. From checking the error code, it sounds like you were trying to use it as a static method. LoadLevelAsync returns an AsyncOperation, which you can then check the isDone property of.

AsyncOperation levelLoader = Application.LoadLevelAsync(0);
while(!levelLoader.isDone) yield return null;
// Do stuff

You can also simply yield the operation as shown in the documentation

Here is how I accomplished this:

IEnumerator Start()

		Application.LoadLevelAdditive("Level 1");

		int loopCount = 0;
		while (true) {
			if (null != GameObject.FindGameObjectWithTag("Level Geometry")) {

			if (500 == loopCount) {
				Debug.LogWarning("Waited 500 fixed updates for level geometry to appear. Aborting.");
				yield break;
			yield return new WaitForFixedUpdate();

// Stuff that requires the level to be loaded.

Of course YMMV.