关键代码:
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
canvas.enabled = !canvas.enabled;
Pause();
}
}
public void Pause()
{
Time.timeScale = Time.timeScale == 0 ? 1 : 0;
}