using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LevelExit : MonoBehaviour { void OnTriggerEnter2D(Collider2D other) { int currentSceneIndex = SceneManager.GetActiveScene().buildIndex; int nextSceneIndex = currentSceneIndex + 1; if (nextSceneIndex == SceneManager.sceneCountInBuildSettings) { nextSceneIndex = 0; } FindObjectOfType().ResetScenePersist(); SceneManager.LoadScene(nextSceneIndex); } }