PlayBackgroundSound
How do I use Play Background Sound
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
15 | MusicController.instance.PlayBackgroundSound (); | 1 |
32 | public void PlayBackgroundSound(){ | 2 |
File name: MainMenuController.cs
Copy
12 void Start () {
13 if(GameController.instance && MusicController.instance){
14 if (GameController.instance.isMusicOn) {
15 MusicController.instance.PlayBackgroundSound ();
16 } else {
17 MusicController.instance.StopAllSound ();
18 }
19 }
20 }
File name: MusicController.cs
Copy
32 public void PlayBackgroundSound(){
33 if(background){
34 audioSource.clip = background;
35 audioSource.volume = 0.5f;
36 audioSource.loop = true;
37 audioSource.Play ();
38 }
39 }
PlayBackgroundSound 118 lượt xem
Gõ tìm kiếm nhanh...