You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
729 B
C#

3 years ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenuButton : MonoBehaviour {
public static GameObject menuInstance;
void Awake()
{
DontDestroyOnLoad(this.gameObject);
if (menuInstance == null) {
menuInstance = this.gameObject;
} else {
Destroy(this.gameObject);
}
}
// Use this for initialization
void Start () {
}
void Update() {
if (Input.GetKey (KeyCode.Escape)) {
if (SceneManager.GetActiveScene ().buildIndex != 0)
SceneManager.LoadScene (0, LoadSceneMode.Single);
else
Application.Quit ();
}
}
public void LoadMainMenu()
{
SceneManager.LoadScene(0, LoadSceneMode.Single);
}
}