using UnityEngine; using UnityEngine.SceneManagement; [RequireComponent(typeof(CanvasGroup))] public class GameOverMenu : MonoBehaviour { public GameState GameState; private CanvasGroup Canvas; private void Awake() { Canvas = GetComponent(); UpdateCanvas(true); } private void Update() { UpdateCanvas(false); } private void UpdateCanvas(bool instantTransition) { bool IsGameOver = GameState.Current == State.GameOver; Canvas.alpha = Mathf.Lerp(Canvas.alpha, IsGameOver ? 1 : 0, instantTransition ? 1 : 2f * Time.deltaTime); Canvas.blocksRaycasts = IsGameOver; Canvas.interactable = IsGameOver; } public void Replay() { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } public void Exit() { Application.Quit(); } }