- Home /
UI button loading wrong scene
I'm trying to make an instructions button on my menu to load a different scene with instructions, but when i click on it, it loads the scene that 'Play' is supposed to load.
public string level;
void Update(){
if (Input.GetMouseButtonDown (0)) {
SceneManager.LoadScene (level);
}
}
This is my code, and I've changed the level on each game object to the correct scene, but it still doesn't work. If i deactivate the Play button, the instructions button will load the correct scene. Any help?
Answer by CrashCZ · Jan 13, 2018 at 05:37 PM
Maybe you should try this
public Button button;
public string level;
public void OnEnable()
{
button.onClick.AddListener(delegate {Load();});
}
public void Load()
{
SceneManager.LoadScene(level);
}
Your answer
Follow this Question
Related Questions
Previous UI text sticks around even after reloading scene using SceneManager.LoadScene(scene.name); 0 Answers
UI Scene ending with Text 1 Answer
Scene loading delay after upgrade 4.6 to 5. 0 Answers
How to make buttons have sound when it is highlighted and clicked? 0 Answers
How Do I Link Different Scenes? 4 Answers