LoadLevelAsync is quite incomprehensible for me.
I have two scene and one cs file attached to each other’s MainCamera. Button on first one should load second scene and show loading image during the process. Here is code.
private AsyncOperation asyncOperation; public void OnGUI() { if (GUI.Button (Rect (20,40,80,20), "Level 1")) asyncOperation = Application.LoadLevelAsync("Scene2"); if(asyncOperation != null && asyncOperation.isDone != true) { //RotateImage matrixBackup = GUI.matrix; GUIUtility.RotateAroundPivot(angle,
pivotPoint);
GUI.DrawTexture(new Rect((Screen.width)/2 - 15,
Screen.height/2 - 15,
30,30), loadingTexture);
angle+=1;
GUI.matrix = matrixBackup;GUI.Box(new Rect(Screen.width/2-30,
Screen.height/2+30,65, 30),
“Loading…”,guiStyle);} }
In Awake() on the second scene I have for loop which lasts about 5 second. I want to gain that, before methods in Awake() are not finished processes to be continued on first scene. For my case first scene freezes(image does not rotate), waits while Awake() finishes and then switches scene immediately.