| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using System.IO;
- public class MainMenu : MonoBehaviour
- {
- public Button continueButton; // Link this in the inspector
- public string gameSceneName = "Valley";
- // Static variable persists between scene loads
- public static bool shouldLoadSave = false;
- void Start()
- {
- // Disable the Continue button if no save file exists
- string path = Application.persistentDataPath + "/savegame.json";
- if (continueButton != null)
- {
- continueButton.interactable = File.Exists(path);
- }
- }
- public void NewGame()
- {
- shouldLoadSave = false;
- SceneManager.LoadScene(gameSceneName);
- }
- public void ContinueGame()
- {
- shouldLoadSave = true;
- SceneManager.LoadScene(gameSceneName);
- }
- public void QuitGame()
- {
- Application.Quit();
- }
- }
|