ReisenTasker/Assets/Scripts/LevelSwitcher.cs

37 lines
673 B
C#

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;
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);
}
}