ReisenYoumuOuting/Assets/Scripts/LevelSwitcher.cs

28 lines
619 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;
}
instance = this;
DontDestroyOnLoad(this);
}
#endregion
public DialogueScript currentScript;
public void SwitchLevel(int sceneIndex, DialogueScript scriptToShow = null)
{
currentScript = scriptToShow;
SceneManager.LoadScene(sceneIndex);
}
}