Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //in game manager
- // pause screen is a UI panel
- //pause menu
- public GameObject pauseScreen;
- private bool paused;
- void ChangePaused()
- {
- if (!paused)
- {
- paused = true;
- pauseScreen.SetActive(true);
- //game slows down to zero speed
- Time.timeScale = 0;
- //lets music play (doesn't require ref to audio source)
- AudioListener.pause = true;
- }
- else
- {
- paused = false;
- pauseScreen.SetActive(false);
- //game plays at normal speed
- Time.timeScale = 1;
- //stops music playing (doesn't require ref to audio source)
- AudioListener.pause = false;
- }
- }
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.P))
- {
- ChangePaused();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement