예제 #1
0
 void Awake()
 {
     backgroundMusicState       = backMusicState.STOPED;
     backgroundMusicSource      = gameObject.AddComponent <AudioSource>();
     backgroundMusicSource.clip = Resources.Load <AudioClip>(FilePaths.soundFolder + "theme");
     soundSource = gameObject.AddComponent <AudioSource>();
 }
예제 #2
0
 public void StopBackgroundMusic()
 {
     if (backgroundMusicSource.isPlaying && backgroundMusicSource != null)
     {
         backgroundMusicSource.Stop();
         backgroundMusicState = backMusicState.STOPED;
     }
 }
예제 #3
0
 public void PauseBackgroundMusic()
 {
     if (backgroundMusicSource.isPlaying && backgroundMusicSource != null)
     {
         backgroundMusicSource.Pause();
         backgroundMusicState = backMusicState.PAUSED;
     }
 }
예제 #4
0
 // background music functions
 public void PlayBackgroundMusic()
 {
     backgroundMusicSource.loop = true;
     if (!backgroundMusicSource.isPlaying)
     {
         if (backgroundMusicState == backMusicState.STOPED)
         {
             backgroundMusicSource.PlayOneShot(backgroundMusicSource.clip, SoundInfo.backgroundSoundInfo.volume * (SoundOptionsGlobal.masterVolume / 100));
             backgroundMusicState = backMusicState.PLAYING;
         }
         else if (backgroundMusicState == backMusicState.PAUSED)
         {
             backgroundMusicSource.UnPause();
             backgroundMusicState = backMusicState.PLAYING;
         }
     }
 }