Can't seem to get Scenemanager.Loadscene() to work

Hi,

I was working on the Quiz Master game after the lectures and I created a new scene to hold my menu. I made a botton which has my gamemanager script connected to it with an method to load a new scene but for some reason it won’t load it.

Can someone please help since I’m stuck on this for hours. Thanks in advance!



Screenshot_3

Hi,

What is “it”? Which button do you press and what is supposed to happen?

According to your screenshot, the top button calls LoadScene and passed on 1. At build index 1, you have the Game scene. Theoretically, the first button should load the the Game scene.

Hi Nina,

Sorry, by “it” I mean the ChooseCategoryButton. As you can see, On Click it wil run the LoadScene method of the GameManager. And yes like you said “theoratically” but for some reason the button will only load the scene if it has already been loaded in the hierachy and this doesnt work well with the Awake method I have in another script ( I did make a build aswell and there this alos doesnt work ).

Edit: I also have the GameManager script in the other scene it will load but I tried making an new script for just this scene and that doesnt work either. Also I just added a new method to the gamemanger script that has the Application.Quit() function connected to the QuitButton and this doesnt work either. Could it be that there is a problem with the buttons?

The Application.Quit() method works in the standalone build only, so “not working” is expected in this case.

Regarding the LoadScene method, I would suggest to add a Debug.Log. Maybe the button click does not trigger the method.

Is there an EventSystem in your Hierarchy? If not, add one. Without an event system, the UI elements do not react to user input.

Thank you!! That did the trick.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.