Different music for pause menu?


I’ve been attempting to achieve this all day and I can’t seem to do it. In my scene, I have a player and two audio sources. One audio source is playing the music I want for the scene (level), and the other audio source is playing the song that I want to be audible in the pause menu. When the player presses the Escape Key, a pause menu pops up. Is there any way I can get one audio source to mute, and the other audio source to unmute when the player hits the escape key? Both audio sources are attached to Empty GameObjects with 2D sounds. Thank you so much for taking the time to help me out!! Thank you!

One way would be to attach the following simple script to both audio sources:

	if (Input.GetKeyDown(KeyCode.Escape)) {
		audio.mute = !audio.mute;

And then in the inspector, set the audio source of the scene to not muted, and the audio source of the pause menu to muted. Every time you press Escape, each audio source will switch from mute to unmute.

A more robust way to do this would be whenever you are opening the pause GUI, to mute one source and unmute the other, but you didn’t share enough of your scripts for me to help you with more than the general idea.