31 lines
641 B
C#
31 lines
641 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class PauseController : MonoBehaviour
|
|
{
|
|
|
|
public bool isPaused = false;
|
|
public GameObject pauseMenuCanvas;
|
|
|
|
void Awake() {
|
|
TogglePauseMenu(false);
|
|
}
|
|
|
|
void OnPause() {
|
|
if (!isPaused) {
|
|
Time.timeScale = 0;
|
|
TogglePauseMenu(true);
|
|
} else {
|
|
Time.timeScale = 1;
|
|
TogglePauseMenu(false);
|
|
}
|
|
isPaused = !isPaused;
|
|
}
|
|
|
|
void TogglePauseMenu(bool showPauseMenu) {
|
|
pauseMenuCanvas.SetActive(showPauseMenu);
|
|
}
|
|
}
|