fix: Delete old scene controllers when switching back to the main menu

This commit is contained in:
Nicholas Novak 2023-05-04 22:16:43 -07:00
parent 97419d36de
commit cd7195ffd1

View File

@ -16,6 +16,10 @@ public class SceneController : MonoBehaviour
{ {
Instance = this; Instance = this;
} }
else
{
Destroy(this);
}
// Make this object stay around when switching scenes // Make this object stay around when switching scenes
DontDestroyOnLoad(this.gameObject); DontDestroyOnLoad(this.gameObject);
SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneLoaded += OnSceneLoaded;