40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class MainMenuManager : MonoBehaviour
|
|
{
|
|
[Header("Scene Settings")]
|
|
[Tooltip("The exact name of the scene you want to load when starting a new game (e.g. 'Level1' or 'WorldMap').")]
|
|
public string newGameSceneName = "Level1";
|
|
|
|
/// <summary>
|
|
/// Call this method from the 'On Click ()' event of your Start Game Button.
|
|
/// </summary>
|
|
public void StartNewGame()
|
|
{
|
|
Debug.Log($"[MainMenuManager] Handing off to LevelLoader for: {newGameSceneName}...");
|
|
|
|
// Pass the request to our global LevelLoader which will handle the loading screen!
|
|
LevelLoader.LoadLevel(newGameSceneName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Call this method from the 'On Click ()' event of your Quit or Exit Button.
|
|
/// </summary>
|
|
public void ExitToDesktop()
|
|
{
|
|
Debug.Log("[MainMenuManager] Exiting to Desktop...");
|
|
|
|
// This closes the actual built game executable (.exe)
|
|
Application.Quit();
|
|
|
|
// If you are testing this inside the Unity Editor, Application.Quit() does nothing.
|
|
// This preprocessor directive forcefully stops Play Mode so you can still test the quit button!
|
|
#if UNITY_EDITOR
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
#endif
|
|
}
|
|
}
|