I have a pause script where I pauses the time and the audio.
The problem I have is that I want to add some button sound effect to my pause menu, but it wont work because I have the code “AudioListener.pause = true;” when the game is paused.
Is there anyway I can make this work?
Rather than setting AudioListener to pause what you could do is get a list of all the audio sources
// Try this piece of code
public var thisAudio:AudioSource; // Assign the audio source that will play the sound
private var sources:List<AudioSources> = new List<AudioSources>();
sources = GameObject.FindObjectsOfType(AudioSources) as (AudioSource);
Time.timeScale = 0;
Time.timeScale = 1;
for(int i=0; i < sources.Count;i++)
if(sources *!= thisAudio)*
sources*.volume = 0;*
for the Enabling the audio just do the reverse for what you did for the DiableAudio