Mute
How do I use Mute
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
18 | if (!SystemScr.mute) | 1 |
24 | if (SystemScr.mute) | 2 |
41 | if (SystemScr.mute) | 3 |
49 | if (SystemScr.mute) | 4 |
41 | if (SystemScr.mute) | 5 |
146 | public void Mute_btn() | 6 |
23 | if (!SystemScr.mute) | 7 |
50 | public void Mute_btn() | 8 |
File name: SoundManager.cs
Copy
16 void Start()
17 {
18 if (!SystemScr.mute)
19 PlayMusic(true);
20 }
File name: SoundManager.cs
Copy
22 public void PlaySoundsPlayer(int soundNumber)
23 {
24 if (SystemScr.mute)
25 return;
26
27 if (soundNumber == 0)
28 audSources[0].clip = shot;
29 else if (soundNumber == 1)
30 audSources[0].clip = p_harm;
31 else if (soundNumber == 2)
32 audSources[0].clip = p_dead;
33 else if(soundNumber == 3)
34 audSources[0].clip = pickup;
35
36 audSources[0].Play();
37 }
File name: SoundManager.cs
Copy
39 public void PlaySoundsEnemy()
40 {
41 if (SystemScr.mute)
42 return;
43 audSources[1].clip = dead;
44 audSources[1].Play();
45 }
File name: SoundManager.cs
Copy
47 public void PlaySoundsUI(bool buttonSound)
48 {
49 if (SystemScr.mute)
50 return;
51 if (buttonSound)
52 audSources[2].clip = button;
53 else
54 audSources[2].clip = pause;
55
56 audSources[2].Play();
57 }
File name: UIgame.cs
Copy
31 void Start()
32 {
33 if (SystemScr.difficultyIsHard)
34 maximumScore = 2000;
35 else
36 maximumScore = 1000;
37
38 scoreText.text = score + "/" + maximumScore;
39 scoreAchived = false;
40
41 if (SystemScr.mute)
42 muteText.text = "ON";
43 }
File name: UIgame.cs
Copy
146 public void Mute_btn()
147 {
148 if (SystemScr.mute)
149 {
150 sounds.PlaySoundsUI(true);
151
152 muteText.text = "OFF";
153 SystemScr.mute = false;
154
155 sounds.PlayMusic(true);
156 }
157 else
158 {
159 muteText.text = "ON";
160 SystemScr.mute = true;
161
162 sounds.PlayMusic(false);
163 }
164 }
File name: UIstart.cs
Copy
20 void Start()
21 {
22 //setup mute text
23 if (!SystemScr.mute)
24 {
25 muteText.text = "OFF";
26 music.Play();
27 }
28 else
29 muteText.text = "ON";
30
31 //setup difficulty text
32 if (SystemScr.difficultyIsHard)
33 difficultyText.text = "HARD";
34 else
35 difficultyText.text = "EASY";
36
37 }
File name: UIstart.cs
Copy
50 public void Mute_btn()
51 {
52 //off mute
53 if (SystemScr.mute)
54 {
55 muteText.text = "OFF";
56 SystemScr.mute = false;
57
58 music.Play();
59 }
60 else//on mute
61 {
62 muteText.text = "ON";
63 SystemScr.mute = true;
64
65 music.Stop();
66 }
67 }
Mute 143 lượt xem
Gõ tìm kiếm nhanh...