Pause Menu Music

Updated on April 3, 2018 in [A] Brackeys Courses
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on April 3, 2018

I have music in my game and when I pause it I can not figure out how to make it stop when I pause. (Beginner)

  • Liked by
Reply
0 on April 3, 2018

You could either link the music pausing to the same button you pause the game with, or you could have the music check if the game is paused, and if it is, pause the music too.

 

The latter would look something like this:

void Update()
{
     if(Time.timeScale == 0f)
     {
          audioSource.Pause();
     }
     else if(ausioSource.isPlaying == false)
     {
          audioSource.Play();
     }
}
  • Liked by
Reply
Cancel