Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class ExitMenu : MonoBehaviour
- {
- // Get the canvas game object
- public GameObject canvas;
- // Update is called every frame
- void Update()
- {
- // If the user pressed the escape key
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- // If the canvas is already active
- if (canvas.activeSelf == true)
- {
- // Disable the canvas
- canvas.SetActive(false);
- }
- else
- {
- // Enable the canvas
- canvas.SetActive(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement