using UnityEngine; using UnityEngine.SceneManagement; public class LevelSwitcher : MonoBehaviour { #region Statication public static LevelSwitcher instance; private void Awake() { if (instance != null && instance != this) { Destroy(gameObject); return; } DontDestroyOnLoad(this); instance = this; } #endregion [SerializeField] private int mapSceneIndex; [SerializeField] private int microGameSceneIndex; public void LoadMap(Map requestedMap, int exitIndex) { SceneManager.LoadScene(mapSceneIndex); Map newMap = Instantiate(requestedMap); newMap.Load(); //load player and set to exit position } public void SwitchMenu(int sceneIndex) { SceneManager.LoadScene(sceneIndex); } public void LoadMicroGame(MicroGameHandler gameToLoad) { SceneManager.LoadScene(microGameSceneIndex); Instantiate(gameToLoad); //instantiate the handler //go from there } }