I want to make the type of my variable a scene, I have tried the following:
var sceneToLoad : Scene;
var SceneToLoad : scene;
but neither seems to work, can someone tell me what I have to type in for the variable type to make it so that you can enter a scene into the variable???
I wanted to do this because then doesn’t matter if you decide to change the scene names in Unity. It turns out you can do it by using the base Object type:
public Object nextScene;
and then use the “name” member variable:
There is no “Scene” object within Unity. The only way to work with scenes is to use: Application.loadedLevel and Application.loadedLevelName together with Application.LoadLevel.
var sceneName : string = "MainMenu";
var sceneIndex : int = 0;
Application.LoadLevel(sceneName); // Load level by name
Application.LoadLevel(sceneIndex); // Load level by index number
This is a fairly dated question, so this may not have been true back when it was asked. But, for what it’s worth, there is a Scene type located in UnityEngine.SceneManagement. The SceneManager class appears to be able to do what you’re looking for…
Scene scene = SceneManager.GetSceneByName("Scene Name");
Hope this helps.
Actually there is a “scene type”: EditorBuildSettingsScene. But its only available to editor scripts and only helps so much. But you can use this to add scenes to your build from script like shown here for example: Adding Scene to build - Questions & Answers - Unity Discussions