Hi,
I’m using Unity to build a game but I want to add a start screen to it, with buttons for Level 1, Level 2, Level 3 and Level 4. I want the buttons, once pressed on, to go straight to that level and if the player passes it, to continue on with the next randomly generated levels. (I’m basing the game off the Unity 2D Roguelike Tutorial)
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement; // Allows SceneManager to be used.
public class LoadSceneOnClick : MonoBehaviour
{
public void LoadByIndex(int sceneIndex) // Passes in what scene will be loaded.
{
SceneManager.LoadScene(sceneIndex); // SceneManager loads scene.
}
}
This is my code for my LoadSceneOnClick script that I am using for each of my main menu buttons. I got this from the Creating A Main Menu tutorial. However it is not working because it assumes that each level is a different scene. This game contains all its levels in a single scene so I’m not sure how to make this work. I’ve tried passing in the variable for level instead of sceneIndex but it did not work, so maybe I was not doing it right.
Any help would be appreciated!!
Thanks