ofb/Assets/Scripts/PauseController.cs
2023-04-27 12:27:15 -07:00

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);
}
}