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


public class Pause : MonoBehaviour {
	public bool pause;
	public GUIStyle but2;

	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown(KeyCode.Escape))
		{
			ToggleP();
		}
		
	}

	public bool ToggleP()
	{
		if(pause)
		{
			pause = false;
			Time.timeScale = 1;
			return (false);
		}
		else
		{
			pause = true;
			Time.timeScale = 0;
			return (true);
		}
	}

	void OnGUI()
	{
		float scrw = Screen.width/16;
		float scrh = Screen.height/9;
		if(pause)
		{
			if(GUI.Button(new Rect(5*scrw,3.5f*scrh,6*scrw,2*scrh),"",but2))
			{
				SceneManager.LoadScene(0);
			}
		}


	}
}
