JamesMakesGames

PauseController

May 27th, 2022
2,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class PauseController : MonoBehaviour
  4. {
  5.     void Update()
  6.     {
  7.         if (Input.GetKeyDown("Escape"))
  8.         {
  9.             GameState currentGameState = GameStateManager.Instance.CurrentGameState;
  10.             GameState newGameState = currentGameState == GameState.Gameplay
  11.                 ? GameState.Paused
  12.                 : GameState.Gameplay;
  13.  
  14.             GameStateManager.Instance.SetState(newGameState);
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment