- Home /
LoadLevelAsync multiple pending scenes?
I'm trying to create a system that loads the main menu and the next scene in the background. I want this because I don't want the user to wait a long time for the level to load after pressing "next level". Here is what I have so far:
private AsyncOperation nextLevel;
private AsyncOperation mainMenu;
void Start () {
nextLevel = Application.LoadLevelAsync (Application.loadedLevel + 1);
nextLevel.allowSceneActivation = false;
mainMenu = Application.LoadLevelAsync (0);
mainMenu.allowSceneActivation = false;
}
public void goToNextLevel () {
nextLevel.allowSceneActivation = true;
}
public void goToMainMenu () {
mainMenu.allowSceneActivation = true;
}
As you can see, I define 2 AsyncOperations for 2 scenes. I then allow scene activation later in different functions. When I call goToMainMenu()
nothing happens. How can I load multiple scenes in the background but not switch to them unless the user calls a function?
Application.LoadLevel("scene")
takes a long time for large scenes. I want to load the next scene in the background so that the switch can happen instantly. Imagine a simple pac-man game. Would you really want to wait a few seconds after each level?
I have the same problem. Have you found a solution?
Hi, why not using Application.LoadLevelAdditiveAsync. It will load the objects from the new scene without destroying the objects of the current scene. You can remove them later if you maintain yourself a list of objects from a scene or another (using the Transform hierarchy makes it quite easy). I don't know if you can load 2 scenes in a row like this, but it's possible and easy to chain the loading operations.
Your answer
Follow this Question
Related Questions
How to make Input.GetAxis work on certain area only? 0 Answers
UnityEngine.UI.dll 0 Answers
How Do I display Search results using Input Fields? 2 Answers
I'm trying to allow my character to only jump when grounded 1 Answer
How to assign one script on different gameobject of 1 prefab and make them run one by one 0 Answers