- Home /
Question by
katiecuon · Nov 28, 2016 at 08:08 AM ·
scripting problemscenescene-loadingbuild settings
"Scene couldn't be loaded because it isn't added to the build settings" but it is?
Objective:
To get the scene to change after clicking "Start" in-game
What Happens:
I get the following error:
Scene '' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.
To add a scene to the build settings use the menu File->Build Settings...
Which is strange, because I did configure my build settings.
Here's what my code looks like:
using UnityEngine;
using System.Collections;
public class LevelManager : MonoBehaviour {
public void LoadLevel (string name){
Debug.Log("Level load requested for: "+name);
Application.LoadLevel(name);
}
public void QuitLevel ()
{
Debug.Log ("I want to quit!");
}
}
What's causing this error? Thanks in advance!!
unity-2016-11-27-19-02-01.png
(54.2 kB)
Comment
Answer by LK84 · Nov 28, 2016 at 08:16 AM
Scene ' ' (-1) --> The string is obviously empty, the compiler is looking for a scene called '', hence you get the error. Go to the part of the code where you call LoadLevel(string name)
and check the parameter.