Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Changing AudioMixer Volume doesn't seem to change volume in standalone build.

Discussion in 'Audio & Video' started by Andrew900460, May 20, 2023.

  1. Andrew900460

    Andrew900460

    Joined:
    Aug 9, 2017
    Posts:
    39
    So, there is a lot to unpack here...

    I have some code that sets the exposed volume values each frame for my different mixer groups. That sentence sounds like a mouth full, so I hope that isn't confusing. Just trying to be 100% clear about things.
    Anyway.

    I am setting the volumes of my AudioMixer groups through code.
    I also have UI sliders which can update my internal "volume variables".
    So when I run my game in the editor, and I move these sliders, I can see the volume sliders in the AudioMixer window change accordingly, as they should. 100% as intended.

    But, If I make a build of my game, run the build, and do the same test, the audio does not appear to change at all. As in, you can hear the music that plays, but when I change my "Master Volume" slider, the music does not get quieter. It doesn't change at all.

    Although, I have proven that the exposed parameters do seem to be getting the updated values (from tests I've done). And also, when I use my sliders, they save the volumes to a config file. And when the game runs, it loads that config and uses those values for the sliders and audio mixer.
    So it seems to me that for some reason, the AudioMixer is getting the values, but not doing anything with them in a standalone build.

    I've not had this issue in the past. Recently I've been making changes to our UI system which also changes how the volume sliders work. So somthing I changed about somthing caused this issue...
    So I assume it's probably somthing dumb that Unity is expecting me to do, but I have no idea.
     
  2. Andrew900460

    Andrew900460

    Joined:
    Aug 9, 2017
    Posts:
    39
    After some more testing, it seems like the issue may be related to Addressable Assets.
    I used Addressables to make my AudioMixer object accessible without needing a dedicated Monobehavior to plug a refernce into. Because I have no reason to need to do that, I just need to load the thing in when the game starts.

    So I was using Addressables to get the AudioMixer, and it did seem to load it properly, but for some reason it had no effect over sound, almost as if the object I was getting was completely different from the one that was being provided to me.

    I then tried putting the AudioMixer into a Resource folder and loading it using the Resources API. Now that does seem to work. So I will go with that, but I am kinda dissapointed in this strange issue with addressables...

    I like using Addressables to load in "single global objects" that I know I will use in a variety of places. I have some code that is also very **non scene dependent**. Meaning I don't have the ability to just use a monobehavior and "plug in" the reference in an inspector. It makes no sence to rely on the inspector in this way. It can all be done in the code.
     
  3. KeigoTakamura

    KeigoTakamura

    Joined:
    Mar 8, 2022
    Posts:
    5
    I observed a similar issue in my project as well
    If the game object to which AudioSource is attached is generated from Addressable, although it can be referenced without any problem in C#,
    AudioMixerGroup volume changes were not reflected.

    The problem was solved by moving the AudioSource to the object originally placed in the Scene and outputting it, but it took a whole day to solve this problem, but thanks to this issue it was solved quickly.
    Thank you.
    If I have time, I would like to create a minimal reproduction project and publish it as an issue, but I don't know if I can do it...

    Reproduction environment below
    ・Unity: 2021 3.20f1
    ・Addressable 1.20.5
    ・Windows Build (Windows 10)
     
    SeventhString likes this.