- Home /
Current scene execution stops before next scene is fully loaded!
Hello,
I have a separate scene named "Loading" , which I load before any "big" scene is loaded. Of course scene "Loading" is light and almost empty which loads fast. I want to display cool staff inside this scene and since every time I want the same loading animation to appear, I preferred to have a separate scene.
Here's the script that manages the "Loading" scene.
public var backgroundGUI:GUITexture;
public static var levelToLoad:String;
function Start ()
{
backgroundGUI.pixelInset.width = Screen.width;
backgroundGUI.pixelInset.height = Screen.height;
}
function Update ()
{
if(Application.GetStreamProgressForLevel(levelToLoad) == 1)
{
Application.LoadLevel(levelToLoad);
}
}
And here's the script that Loads this scene:
// of course this if conditional is inside GUI , checking for touch , etc ...
if(button1_guiTexture.HitTest(Input.GetTouch(0).position , mainCamera))
{
levelButtonSound.Play();
LoadLevel("Jungle");
}
function LoadLevel(levelToLoad:String)
{
Loading_Manager.levelToLoad = levelToLoad;
Application.LoadLevel("Loading");
}
As you see clearly in the code, I change the level name and load the "Loading" scene, which in turn plays a Background and Loads the appropriate Scene.
What I can't do is applying any animation or percentage display or anything once Application.LoadLevel(levelToLoad) is called.
I need a way to keep the Update function running untill the next level fully loads. Or any other different method that can make this work.
Thank you for your time :)
Answer by Bunny83 · Mar 25, 2013 at 04:55 PM
This is only possible with Application.LoadLevelAsync which is a unity pro feature. The normal LoadLevel function blocks until the level is loaded. No frame is drawn during the loading.
@Bunny83 thanks, it seems to solve my problem, but causing me another strange problem!
The game is not playable! so strange, the assets shake, even the touch control stops ocasionally .. some type of crash, I switched back to the old method, everything runs smoothly now.
I did use it like this: Application.LoadLevelAsync(levelToLoad); Just like LoadLevel.. what might cause this?
Well , I created a separate scene for loading, and put the "Application.LoadLevelAsync" in the start function of the the loading scene.
Your answer
Follow this Question
Related Questions
How to have GearVR play smooth during LoadLevelAsync 0 Answers
Delays when move to another scene 1 Answer
Next lvl code help 1 Answer
level load problem 2 Answers
Giant spike with level load causes crash with iphone 1 Answer