-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPauseMenu.cs
45 lines (39 loc) · 1.29 KB
/
PauseMenu.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public GameObject pauseMenuUI;
public void PauseGame()
{
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
FindObjectOfType<AudioManager>().Play("ButtonSound");
}
if (PlayerPrefs.GetInt("MusicEnabled", 1) == 1)
FindObjectOfType<AudioManager>().Pause("GameMusic2");
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
}
public void ResumeGame()
{
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
FindObjectOfType<AudioManager>().Play("ButtonSound");
}
if (PlayerPrefs.GetInt("MusicEnabled", 1) == 1)
FindObjectOfType<AudioManager>().PlayWithFadeIn("GameMusic2", 0.5f);
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
}
public void MainMenu()
{
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
FindObjectOfType<AudioManager>().Play("ButtonSound");
}
SceneManager.LoadScene(0);
Time.timeScale = 1f;
if (PlayerPrefs.GetInt("MusicEnabled", 1) == 1)
FindObjectOfType<AudioManager>().PlayWithFadeIn("GameMusic", 1f);
}
}