Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PauseUI : MonoBehaviour
- {
- [SerializeField] private GameObject gamePanel;
- [SerializeField] private GameObject pausePanel;
- private bool _isActive;
- private void Start()
- {
- _isActive = false;
- pausePanel.SetActive(_isActive);
- gamePanel.SetActive(!_isActive);
- }
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- SetOnPanel(pausePanel, !_isActive);
- SetOnPanel(gamePanel, _isActive);
- _isActive = !_isActive;
- }
- }
- private void SetOnPanel(GameObject panel, bool value)
- {
- panel.SetActive(value);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment