Skip to content

Instantly share code, notes, and snippets.

@SenpaiRar
Last active May 15, 2019 01:27
Show Gist options
  • Save SenpaiRar/c567063f0f87c041627f54513d4a237d to your computer and use it in GitHub Desktop.
Save SenpaiRar/c567063f0f87c041627f54513d4a237d to your computer and use it in GitHub Desktop.
This is the script for the escape menu.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//We import Unity UI, but we also import something else!
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class EscapeMenu : MonoBehaviour
{
public KeyCode EscapeKey;
private bool EscapeMenuUp;
public Canvas EscapeMenuCanvas;
void Start(){
EscapeMenuUp=false;
EscapeMenuCanvas.enabled = false;
}
void LateUpdate(){
if(Input.GetKeyUp(EscapeKey)){
if(EscapeMenuUp == false){
EscapeMenuCanvas.enabled = true;
EscapeMenuUp = !EscapeMenuUp;
}
else if(EscapeMenuUp == true){
EscapeMenuCanvas.enabled = false;
EscapeMenuUp = !EscapeMenuUp;
}
}
}
public void OnMainMenuButton(){
SceneManager.LoadScene(0);
}
public void onQuitButton(){
Application.Quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment