22 lines
569 B
C#
22 lines
569 B
C#
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class PauseMenu : MonoBehaviour {
|
|
public bool Paused = false;
|
|
|
|
private CanvasGroup Canvas;
|
|
|
|
private void Awake() {
|
|
Canvas = GetComponent<CanvasGroup>();
|
|
}
|
|
|
|
private void Update() {
|
|
if (Input.GetKeyDown(KeyCode.Escape)) {
|
|
Paused = !Paused;
|
|
}
|
|
|
|
Time.timeScale = Mathf.Lerp(Time.timeScale, Paused ? 0 : 1, 10f * Time.unscaledDeltaTime);
|
|
Canvas.alpha = Mathf.Lerp(Canvas.alpha, Paused ? 1 : 0, 10f * Time.unscaledDeltaTime);
|
|
}
|
|
}
|