Hi, i have one unity app which has multiple games, each has its own camera for audio listener and audio source. I want to make a global sound control for app.
all the game has its own audio source with volume = 1.
AudioListener.volume = 0.3f; to control sound. in a global script
It does work, but the volume doesnt increase or decrease as normally.
eg. to make sound 30% , i should do 0.3
but i have to do like 0.003 or something like this, to see the actual sound decreasing.
I cant change each game audio source volume, that is why i am going through audio listener.
how and why is this happening ? anyone has any idea ?
I think it wont help, i dont want to access the audio source at run time of each game that is being played and assign it to mixer then control . It is not a good idea i think.
I have to say that using the AudioMixer is probably the good pattern to follow, especially if you’re working on global volume. If you’re spawning you audio sources via scripts, it should not be complicated to assign them to a mixer group, if I recall correctly I think that can even be done through a prefab.
About setting the volume to the “expected” levels, what you’re experiencing is due to the nature of sound. The volume value you are using has a linear impact on the audio signal, while loudness is perceived in a logarithmic way.
I recommend you try to play with your sound by thinking in decibel:
linearVolume = Mathf.Pow(10, dB / 20); dB = Mathf.Log10(linearVolume) * 20;