Advertisement
ChrisTutorials

Main Menu MonoBehaviour

Jul 1st, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6.  
  7. public class MainMenu : MonoBehaviour {
  8.     public Button newGameButton;
  9.     public Button loadButton;
  10.     public Button exitGameButton;
  11.     public string newGameSceneName;
  12.  
  13.     public GameObject loadGameMenu;
  14.  
  15.     public void Awake() {
  16.         newGameButton.onClick.AddListener(NewGame);
  17.         loadButton.onClick.AddListener(OpenLoadGameMenu);
  18.         exitGameButton.onClick.AddListener(ExitGame);
  19.     }
  20.  
  21.     public void NewGame() {
  22.         SceneManager.LoadScene(newGameSceneName);
  23.     }
  24.  
  25.     public void OpenLoadGameMenu() {
  26.         loadGameMenu.SetActive(true);
  27.     }
  28.  
  29.     public void ExitGame() {
  30.         Debug.Log("Trying to exit game. Doesn't work in editor.");
  31.         Application.Quit();
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement