I think my code must be pretty close, but I can’t get a keyboard key to take me to the next scene. I have attached the script for the next scene to the button and it is selected in the onclick () area in the inspector tool. My code is as follows:
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneLoader : MonoBehaviour
{
public void update()
{
{
if (Input.GetKey(KeyCode.return))
{
LoadNextScene();
}
}
}
public void LoadNextScene()
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex + 1);
}
public void LoadStartScene()
{
SceneManager.LoadScene(0);
FindObjectOfType<GameSession>().resetScore();
}
public void QuitGame()
{
Application.Quit();
}
}
EDIT: By selecting the update method in the onclick tab I can get the button to carry me to the next scene by first clicking the button and then pressing the keyboard key. How would I eliminate the need for clicking the button initially and therefore, only require me to press the keyboard key?