Код: Выделить всё
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pause : MonoBehaviour
{
public GameObject menu;
public GameObject resume;
public GameObject quit;
public bool isPaused;
// Start is called before the first frame update
void Start()
{
menu.SetActive(false);
}
// Update is called once per frame
void Update()
{
if ( Input.GetKeyDown(KeyCode.Escape))
{
if (isPaused)
{
Resume();
}
else
{
PauseTheGame();
}
}
}
public void Resume()
{
Time.timeScale = 1f;
menu.SetActive(false);
isPaused = false;
Debug.Log("Perfect");
}
public void PauseTheGame()
{
Time.timeScale = 0f;
menu.SetActive(true);
isPaused = true;
}
public void Exit()
{
Application.Quit();
}
}
Подробнее здесь: https://stackoverflow.com/questions/782 ... e-the-game