Asynchronous Loading throws errors :(

Hi,

I’ve got a problem with asynchronous loading of scenes. In StartScreen.cs I do the following

private Loader m_kLoader;

public void OnGUI(){
   ...
   if ( !m_kLoader.isLoading()){
      drawButton();
   }
}

public void drawButton()
{
   ...
   m_kLoader.load( "nextScene");
}

In Loader.cs I do:

public void load( string kSceneToBeLoaded)
{
   StartCoroutine( loadLevel( kSceneToBeLoaded));
}

private IEnumerator loadLevel( string kSceneToBeLoaded)
{
   AsyncOperation async = Application.LoadLevelAsync( kSceneToBeLoaded);

   yield return async;
}

When calling Application.LoadLevelAsync an error is thrown:

m_ThreadCheck  !Thread::EqualsCurrentThreadID(m_ThreadID)

How can I use asynchronous loading? I don’t know why this is a problem in my context… Any ideas? :?

Thanks in advance!

GO at it by starting with the basic to know what is causing your problem. Because even if your error comes on LoadLevelAsync, it doesn’t mean that it’s the only cause of your problem.

I would start with;

private IEnumerator Start() 
{ 
   AsyncOperation async = Application.LoadLevelAsync("levelName"); 

   yield return async; 
}

Does it work?

If it does, go to the next step and so on.

Also, try putting your code in the same class and see what happens.

Keep us updated :wink: