I am making a game, and it has around 32 levels. i have a scene which has a button, with the number level, eg a button with 1, and so on. at the moment i have a Script which loads the scene if the button is pressed, but having to write out 32 different voids going between each scene is a real hassle, is there a way i could do this better?
This is the script that is for the buttons:
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameMaster : MonoBehaviour
{
public void GoToGameScene()
{
SceneManager.LoadScene("Level01");
}
public void Restart()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
public void GoToMainMenu()
{
SceneManager.LoadScene("MainMenu");
}
public void LevelSelect()
{
SceneManager.LoadScene("LevelSelect");
}
}
the level select void is the scene with all the buttons. this is what it looks like
i know it doesnt look the best, but its for testing purposes