Abdula_2314124

Untitled

Mar 20th, 2024
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class PauseUI : MonoBehaviour
  4. {
  5.     [SerializeField] private GameObject gamePanel;
  6.     [SerializeField] private GameObject pausePanel;
  7.     private bool _isActive;
  8.  
  9.     private void Start()
  10.     {
  11.         _isActive = false;
  12.         pausePanel.SetActive(_isActive);
  13.         gamePanel.SetActive(!_isActive);
  14.     }
  15.  
  16.     private void Update()
  17.     {
  18.         if (Input.GetKeyDown(KeyCode.Escape))
  19.         {
  20.             SetOnPanel(pausePanel, !_isActive);
  21.             SetOnPanel(gamePanel, _isActive);
  22.             _isActive = !_isActive;
  23.         }
  24.     }
  25.     private void SetOnPanel(GameObject panel, bool value)
  26.     {
  27.         panel.SetActive(value);
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment