I made a game object for both the core game scene and the winning scene. I then proceeded to attach a script to both of the game objects and click the “LoadNextScene” Method on both of them. However, only my start scene button works and it takes me to the core game scene.
Is the scene in your screenshot the one with the issue? I see only one button? If this isn’t the scene in question please provide a screenshot of the relevant scene. Also, can you provide a screenshot of the button which isn’t working with its details visable in the Inspector please.
This scene is the one with the issue, yes and I’m having the same issue with the other win scene. And you can see the details of the success button on the screenshot above at the side of the inspector on the “On Click ()” section I hooked up the script file to the game object and the appropriate method. However, its weird, because the button in the start scene works with the game object its just these two particular scenes that refuse to work.
Below you can see a screenshot of my code as well.
Ok, just so I can understand this, you have a scene named Start which has a button on it to, presumably, load the CoreGame scene, and that works correctly.
Then, in the CoreGame scene, and the Win scene, you have buttons which are not working correctly.
Just to check, in the On Click event handler, have you dragged the SceneLoader GameObject from the Hierarchy, or the script from the Assets folder? It needs to be the object from the scene in order for the script to execute.
Could you check and confirm please.
Also, whilst screenshots are handy for error messages and details from the Inspector, it’s typically better to copy/paste your code directly into your posts and then apply code formatting. This would allow those who offer to help to copy/paste parts of your code back with suggestions/corrections without having to type it all out.
public void LoadNextScene()
{
Debug.Log("LoadNextScene has been called");
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex + 1);
}
Ok, so that’s good, in a way, it tells us that your code is definitely not being executed, so we can ignore other things like scenes not being found and so on.
Could you zip up your project files so that I can take a look, it will be a little quicker to diagnose being able to interact with your project myself.
The forum will allow uploads of up to 10MB, if your project files (zipped) are larger than that you would need to use a service such as Google Drive or Dropbox, and then share the URL.
Ok, so compare your Start scene and your Core Game scene Hierarchy and look for differences.
You’ll see that you do not have an Event System in the Core Game scene, this is required in order to handle events such as button clicks, without it, they won’t work.
Right click in the Hierarchy and create a new Event System, run the game and it’ll work fine.
It’s easily done, typically happens if you are just copying objects between scenes, even if you prefabed the canvas it would be easy to not include the Event System.
You’ll learn from this experience though, so next time you have buttons not responding you may find its the first thing you check