I'm in the start screen scene of my game and I'm trying to load the actual game. I use the following code:

public void LoadGame(){
        SceneManager.LoadScene ("Main", LoadSceneMode.Single);

I set this method to be called when a button in the UI is clicked. When testing in the game in the unity IDE, clicking the button doesn't do anything. Is my code wrong, is the IDE screwing up, or will clicking the button never do anything in the ide?

  • \$\begingroup\$ Add Debug.Log("Clicked!"); before SceneManager.LoadScene and check in the console if it gets fired. \$\endgroup\$ – Jacob Jun 18 '17 at 21:10
  • \$\begingroup\$ @Spectre I forgot to add the scene to the build settings....#theTroublesOfANewbie \$\endgroup\$ – Joel J. Jun 18 '17 at 21:15
  • \$\begingroup\$ Yep. And you should get an error in the console saying "Trying to load a scene which is not added to the build" blah blah. Look at the console, always. And debug things with Log()'s \$\endgroup\$ – Jacob Jun 18 '17 at 21:18
  • \$\begingroup\$ If you solved your problem by yourself, post an answer with the solution and accept it :) \$\endgroup\$ – Jacob Jun 18 '17 at 21:18
  • \$\begingroup\$ @Spectre done and thx for the adivce \$\endgroup\$ – Joel J. Jun 18 '17 at 21:19

Turns out the code works. Here "Main" is the name of the scene and LoadSceneMode.Single is one element of an enumeration. Remember to add all scenes to the build settings.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.