# How can I load all of my scenes at startup?

I want all of my scenes to load when the loading screen is shown (but only one should be shown at a time) so I can switch between them quickly I have tried this:

if (Application.GetStreamProgressForLevel (2) == 1) {


and:

(Application.GetStreamProgressForLevel (2) == 1) {

• I reformatted the code to be more readable, but I don't get what it's doing or why it's a problem. – Anko Jan 6 '14 at 14:09

First of all loading all scenes into memory may not be a good idea. Depending on your scene size, you can quickly exhaust all the available memory. In addition why do you want to load additive all your scenes? Eventually use a single scene if you know that you are loading all the scenes anyway.

In any case, just a little clarification. When you load a scene into memory, all the objects in the scene will be added to the hierarchy (scene graph). At that point you cannot distinguish no more which object belong to which scene.

When I want to keep track of which GameObjects belong to which scene (usually when I use load level additive and lightmaps), I organize my scene using a root node for each scene, in such a way that all objects belonging to the scene N, have a common root node Root_N . This way if you want to unload the scene N -1 you can just call Destroy on the relative root GameObject (Root_N -1).

I guess that in a simliar way if you attach a script to the root GameObject of each scene (starting from the second ), that is responsible for disabling the relative node in Start method, you will obtain a similar result.

public class RootSceneHandler : MonoBehavior // attached to the root gameobject. Disabling the root node will provoke each children to become invisible too.
{
void Start()
{
SetActive(false);
}
}