(Help) Game over button not working

Hello guys im just on lecture 63 and im finding it hard to get the game over button to work. It’s reading: ’ Level Win Screen (-1) couldnt be loaded because it has not been added to the build settings. Its weird because, I did add it to the build settings :confused: @Rob

1 Like

Can you pop up a screenshot of Unity with the error displayed, and also one of the build settings please.

ok be right back and how can I attach a screenshot to send?

You can just paste them straight into the post, or using the Upload icon from the Composer Tool bar.


See also;

Level ‘Win Screen’ (-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/Scripts/LevelManager.cs:8)
UnityEngine.EventSystems.EventSystem:Update()

Screenshot of the Build Settings? My guess is that perhaps the scene name has changed but this would help identify that.

In the Build Settings you have added a scene called Win, yet in code you are telling it to load Win Screen.

So, either rename the scene currently named Win to Win Screen or, change the code to load scene Win :slight_smile:


As a bit of extra info, lets run through the error message too;

UnityEngine.Application:LoadLevel(String)
LevelManager:LoadLevel(String) (at Assets/Scripts/LevelManager.cs:8)
UnityEngine.EventSystems.EventSystem:Update()

So, in reverse order, as that would be the order of generation…

UnityEngine.EventSystems.EventSystem:Update()

A method called Update() has been called and an error has occured.

This helps us narrow things down a little bit as we could, at the very least, looking through everything that is happening from within our Update() methods, but it’s still not overly specific or focused. Lets look at the next line…

LevelManager:LoadLevel(String) (at Assets/Scripts/LevelManager.cs:8)

Now we are getting a bit closer to the issue, we are told which specific Script (LevelManager), the method LoadLevel(), it provides the method signature, e.g. (String), this tells us the specific type of method, as we could maybe have a method with the same name that took an Int for example.

After this we get the path to the script and the line number of the offending statement.

Be aware that the line number should be treated as a guide, as your code may error on a line number due to an issue prior to this line number for example, but you can use it to get you very close to the issue.

The final line in the error message;

UnityEngine.Application:LoadLevel(String)

This is where the game truly fell over as your LoadLevel() method was calling the underlying Application.LoadLevel() method. When it tried to do this it failed because the name of the scene provided didn’t existing in the build settings.

I hope that helps to unravel the error message in more detail which may serve you well moving forward :slight_smile:

gotcha :grin:

1 Like

Just updated my reply with some info about the error message which may help in the future also.

Thanks man! And I really truly appreciate your time aswell Rob. Keep up the good work

1 Like

No problem, you’re welcome - and always! :slight_smile:

Again, please mark the topic as solved if this fixed your problem - thanks in advance :slight_smile:

Privacy & Terms