I have a game which opens with a start menu which gives the option of various spawn points within the game. Depending on which start point the user selects will determine the necessary load order for the rest of the levels.
I have tried having a startup event which loads the next level but this only gives me a linear process and not the flexibility I need to optimize loading times.
Can anyone suggest how I can get the above to work?
We’re building a scene to stream over the web. The scene is massive and have had to split it into components and then use an ApplicationLoadLevel to load the next component and DontDestroyOnLoad to keep the last component active.
The problem is depending which option is selected by the user we need the components to load in a different order which is relative to where the user spawns.
Is there a script which will allow me to specify the order to load in the components (in this case individual scenes) in an order of our choice?
Store the order you want to load them in an array (loadOrder) attached to a component called (for example) LevelLoader. The LevelLoader also has a int pointing to a position in the array called (for example) currentLevel (if you use the code below then start it at -1).
LevelLoader has a function something like:
function LoadNextLevel() {
currentLevel++;
Application.LoadLevelAdditive(loadOrder[currentLevel]);
}
In each scene have a component with an Awake() or Start() function that looks up the LevelLoader component (by name/tag/etc), and then calls LoadNextLevel();
Obviously needs a check to stop loading after they are all done, and probably many other tweaks, but thats the general idea.
Also while I’m at it can anyone suggest how to start the next scene from a different camera depending on which option is chosen? I’m thinking making the cameras available through a global or static variable and then activate them from the scripot in the previous scene. Not sure how to do that just yet though.