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.
public var thisAudio:AudioSource; // Assign the audio source that will play the sound
private var sources:List<AudioSources> = new List<AudioSources>();
function Start()
{
sources = GameObject.FindObjectsOfType(AudioSources) as (AudioSource);
}
function Update()
{
if(Input.GetButton("Pause"))
{
Time.timeScale = 0;
DisableAudio();
thisAudio.Play();
}else {
Time.timeScale = 1;
}
}
function DisableAudio()
{
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