Application.LoadLevel error

Level ‘’ (-1) couldn’t be loaded because it has not been added to the build settings.
To add a level to the build settings use the menu File->Build Settings…
UnityEngine.Application:LoadLevel(String)
LevelManager:LoadLevel(String) (at Assets/LevelManager.cs:8)
UnityEngine.EventSystems.EventSystem:Update()

Everything looks right can someone please help me solve this

Alright, so in the console you have 'Level load requested: '. Which shows me that the string being passed from your start button to the LevelManager script is empty. I would click on your start button in the hierarchy, then go to the inspector and make sure that you’ve typed in the name of the level that you want to load.

2 Likes

So I tried what you said but yet it still shows me the same thing I’m so confused

Hello @Nicholas_Fenwick,

In the OnClick event for your selected button in that screenshot you have the value “name” being passed as the parameter for the name of the scene to load.

You need to put the actually name of the scene in that field, e.g. game

Also, pay attention to your use of case as all of your scene names are lower case apart from Win.

So I fixed it and it got rid of the error but it wont change to a new scene aw man I feel like a super rookie


You need to put game in the OnClickEvent.

This will explain what (string name) is doing in your script. In Unity they have many different variables so we have to tell Unity what type of variable to create, Unity can hold many of the same variable so we have to give it a name and then we have to assign something to that variable. So in the case of (string name), the string is the type that we are creating, the name of that string is name and what you put in the OnClickEvent becomes what is assigned to it.

So if you put in start in the OnClickEvent, start will be assigned to the string and Unity will load your start level. Unity did reload your start level, but there isn’t any animations or anything like that yet so it looks the same. If you don’t get this, don’t worry about it. Many of us had issues with coding early on.

Hey @Nicholas_Fenwick,

Don’t beat yourself up, it’s all good, everyone will find something challenging as they progress through these courses, different people will hit different challenges :slight_smile:

So, looking at your screenshots (thanks for those)…

  • You have run the game and the start scene is displayed
  • You have a start button, which you have wired up to load a scene called start (correcting it from “name” previously)

So…

The game runs, the start scene loads, you click the start button, it loads the same scene again! :slight_smile:

You have another scene called game which is the scene which will handle the actual choices of the player / guesses of the wizard.

To fix…

  • Open the start scene.

  • Select the Start button

  • In the OnClick event in the Inspector, change the name of the scene to load to game
    Note - case sensitivity is important here, make sure the name matches the actual name of the scene (“game” not “Game” for example).

  • Save the scene, run the game… :slight_smile:

1 Like

Privacy & Terms