using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MenuManager : MonoBehaviour
{

    private RectTransform mycanvas;

    // Start is called before the first frame update
    void Start()
    {

        mycanvas = transform.Find("Menu").GetComponent<RectTransform>();
        mycanvas.gameObject.SetActive(false);
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {

            PauseAndUnpause();
        }
    }

    public void PauseAndUnpause()
    {


            mycanvas.gameObject.SetActive(!mycanvas.gameObject.activeSelf);
            if (Time.timeScale > 0)
            {
                Time.timeScale = 0f;
            }
            else
            {
                Time.timeScale = 1f;
            }

    }

    public void QuitGame()
    {
        SceneManager.LoadScene("Menu");
    }

}
