using UnityEngine; [System.Serializable] public enum State { Playing, Paused, GameOver } public class GameState : MonoBehaviour { public State Current = State.Playing; private void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { switch (Current) { case State.Playing: Current = State.Paused; break; case State.Paused: Current = State.Playing; break; } } Time.timeScale = Mathf.Lerp(Time.timeScale, Current == State.Paused ? 0 : 1, 10f * Time.unscaledDeltaTime); } }