Does coroutine block the script's thread at loadLevelAdditiveAsync?

Hello guys:
I met a loading problem, i used a coroutine to load the scene in back ground ,but the current script 'update function was blocked…
what i want to do is to use a loadingscene to load the main scene, the loading scene code is
//loadingScene.cs
void onEnter ()
{
StartCoroutine(LoadMainScene());
}

		IEnumerator LoadMainScene()
		{
			load = Application.LoadLevelAdditiveAsync ("MainScene");
			yield return load;
			Debug.Log("load.isDone:" + load.isDone);
		}

               void FixedUpdate()
		{
			this.updatePercent ();
		}
	
		void Update ()
		{		
			Debug.Log("Loading Scene updating...

");
}

               //In MainScene.cs which is link to MainScence.unity
              void Awake ()
	     {
	        Debug.Log("MainScene::Awake(), begin TimeStamp :" + System.DateTime.Now);
                StartCoroutine(InitResouce());		
		Debug.Log("MainMediator::Awake(), end TimeStamp :" + System.DateTime.Now);
	     }


            //this coroutine will block LoadingScene.cs's update... can't get the loading progress.... lead to loading  hiccups
            IEnumerator InitResource()
	    {
                 // do many GameObject.Instantiate(prefabs) as ...;
                 yield return 0;
		Debug.Log("Start finished!");
	}

the result is like :
Loading Scene updating…loading progress:0
Loading Scene updating…loading progress:0.1316038
MainScene::Awake(), begin TimeStamp :09/06/2013 16:51:33
MainScene::Awake(), end TimeStamp :09/06/2013 16:51:35
Loading Scene updating…loading progress:1

the progress is from 0 to 0.13 then directly to 1… it’s not smooth at all…

the InitResource function will cost 2 seconds , and the loading progress bar will stop 2 seconds to wait…

I used a coroutine to do this task… why it still block the Loadingscene.cs script…

Do you guys meet this kinds of problem before?
Any advices will be appreciate…
thanks

22 StartCoroutine(InitResouce());

Typo

A coroutine doesn’t run in a separate thread, but instead execution is “spread out” over several frames. An example is:

void Update()
{
    StartCoroutine(MoveTriangle());
}

IEnumerator MoveTriangle()
{
    for (int i=0; i < 10; ++i)
    {
        triangle.transform.position += direction;
        yield return null;
    }
}

This will move the triangle game object by direction once every frame, after which yields control of the thread.

In your example the InitResource method doesn’t yield control of the thread until it’s finished, when you yield return 0. This has the effect that it will initialise the resources in the first thread, yield and then print out “Start Finished” in the following thread.

If I’m wrong about any of the details of how it works, I’m sure someone can correct me :slight_smile: