28 lines
631 B
C#
28 lines
631 B
C#
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class PauseMenu : MonoBehaviour {
|
|
public GameState GameState;
|
|
|
|
private CanvasGroup Canvas;
|
|
private bool Paused {
|
|
get {
|
|
return GameState.Current == State.Paused;
|
|
}
|
|
}
|
|
|
|
private void Awake() {
|
|
Canvas = GetComponent<CanvasGroup>();
|
|
Fade(true);
|
|
}
|
|
|
|
private void Update() {
|
|
Fade(false);
|
|
}
|
|
|
|
private void Fade(bool instant) {
|
|
Canvas.alpha = Mathf.Lerp(Canvas.alpha, Paused ? 1 : 0, instant ? 1 : 10f * Time.unscaledDeltaTime);
|
|
Canvas.blocksRaycasts = Paused;
|
|
}
|
|
}
|