LoadLevelAsync gives me headache

Hi everybody,

I know there are many discussions about this feature but i couldn’t find any acceptable answer.

My problem is dealing with the assert

m_ThreadCheck  !Thread::EqualsCurrentThreadID(m_ThreadID)

I tried to create a new project just to test this case with a simple code

public class NewBehaviourScript1 : MonoBehaviour {

	// Use this for initialization
	void Start () {
	}
	// Update is called once per frame
	void OnGUI () {
		 if (GUI.Button(new Rect(Screen.width / 2 - 40, 90, 160, 25), "test"))
			 Application.LoadLevelAsync("test");
	}
	
}

I still have the assert.

So I tried an onther piece of code

public class NewBehaviourScript1 : MonoBehaviour {

	// Use this for initialization
	void Start () {
	}
	// Update is called once per frame
	void OnGUI () {
		 if (GUI.Button(new Rect(Screen.width / 2 - 40, 90, 160, 25), "test"))
			 StartCoroutine(LoadMyLevel());
	}
	
	IEnumerator LoadMyLevel()
	{
		 AsyncOperation AO = Application.LoadLevelAsync("test");
		yield return AO;
	}
}

I still have the assert.

However my scene is loaded and I can see It, but I read something that afraid me:

My base scene has just the gameobject MainCamera and this script,

the Scene to load asynchronously has just a Terrain.

So why this assert still appears? Should I ignore it? Something is missing?

Thx for your futur answer guys

Hi,
I would try to make sure Application.LoadLevel ist called twice or more per click.

A small Debug.Log(“Clicked !”); Might help you further.


Oxl

I tried it, and it is called only once :expressionless: