2020-04-18 18:26:35 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
|
|
|
public class PauseMenu : MonoBehaviour {
|
2020-04-19 01:12:29 +02:00
|
|
|
|
public GameState GameState;
|
2020-04-18 18:26:35 +02:00
|
|
|
|
|
|
|
|
|
private CanvasGroup Canvas;
|
2020-04-19 01:12:29 +02:00
|
|
|
|
private bool Paused {
|
|
|
|
|
get {
|
|
|
|
|
return GameState.Current == State.Paused;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-18 18:26:35 +02:00
|
|
|
|
|
|
|
|
|
private void Awake() {
|
|
|
|
|
Canvas = GetComponent<CanvasGroup>();
|
2020-04-19 20:04:45 +02:00
|
|
|
|
Fade(true);
|
2020-04-18 18:26:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update() {
|
2020-04-19 20:04:45 +02:00
|
|
|
|
Fade(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Fade(bool instant) {
|
|
|
|
|
Canvas.alpha = Mathf.Lerp(Canvas.alpha, Paused ? 1 : 0, instant ? 1 : 10f * Time.unscaledDeltaTime);
|
|
|
|
|
Canvas.blocksRaycasts = Paused;
|
2020-04-18 18:26:35 +02:00
|
|
|
|
}
|
|
|
|
|
}
|