using UnityEngine; using UnityEngine.SceneManagement; public class buttons : MonoBehaviour { public void RestartScene() { SceneManager.LoadScene(SceneManager.GetActiveScene().name); } public void NextScene() { UnlockedNewLevel(); int nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1; SceneManager.LoadScene(nextSceneIndex); } public void UnlockedNewLevel() { int currentSceneIndex = SceneManager.GetActiveScene().buildIndex; int reachedIndex = PlayerPrefs.GetInt("ReachedIndex", 0); if (currentSceneIndex >= reachedIndex) { PlayerPrefs.SetInt("ReachedIndex", currentSceneIndex + 1); PlayerPrefs.SetInt("UnlockedLevel", PlayerPrefs.GetInt("UnlockedLevel", 1) + 1); PlayerPrefs.Save(); } } public void GoToScene0() { SceneManager.LoadScene(0); } }