Audio mixer exposed parameters

Hi,

I was wondering if there is a way to access the list of the exposed parameters of an audio mixer from a script. Also, is there a way to know the minimum and maximum values for these parameters ? From the documentation that I found, it seems that it is not possible but it would be really useful for me so I would like to know if I missed something.

Thank you

That’s what they mean by “exposed”. It means the parameters are exposed to script.

GetFloat(string name, out float value);

From a variable referencing a mixer, you can call the GetFloat function, pass it the name of an exposed parameter, and a float variable, and it will fetch the current value and put it in that variable. This function returns false if it cannot find an exposed parameter with the name you passed it.

SetFloat(string name, float value);

From a variable referencing a mixer, you can set an exposed parameter value by calling the SetFloat function and passing it the name of the exposed parameter, and a float that is the new value.

I’m not sure about the max and min of each type of potentially exposed parameter. You may be able to access that from code, but you should also be able to work it out from the GUI

In the AudioMixer GUI you can set the volume from -80dB to +20 dB so this should be the max and min value for the Volume. In Editor values are clamped between -80 and +20 so you can’t even overstep these boundaries.

My problem is that i’m trying to set these values in a custom gui layout in the Inspector (kind of audio manager) so i don’t need to use the AudioMixer GUI.

While in play mode it works, but as soon as I activate Edit in Play Mode it switches back to the Basic Values.
Also it doesn’t work when not in play mode. So it just works on runtime.

Does someone has an idea if it’s possible to make it work in Edit Mode, so I can just handle everything with my script in Inspector and values change live (or wenn GUI is drawn again)?

I know I can access an exposed parameter by its name, but that is not what I am looking for. I want to get all the exposed parameters to create a dropdown list in a custom editor without having to know their names.

2 Likes

That would be useful :expressionless:

1 Like

doesn’t work like that, you have to expose and name specific parameters manually, see this video, the important part starts at 1:00 and ends at about 2:00

https://unity3d.com/learn/tutorials/topics/audio/exposed-audiomixer-parameters

Anyone found any info in this yet?

Here’s the quick answer for anyone who wants to know.
Go to the volume of your audio mixer’s group, right click on it and select “ExposeValue”.

4 Likes

We’re asking for a way to find the exposed parameters via script.

You can get a list of exposed params via reflection. I’m not sure if you can figure out the min/max values, or even what those params are binded to. So, getting a list of names of exposed params is probably not useful for most people.

1 Like

Hey guys! I know this is a really old thread, but I found a solution:

private List<string> GetExposedParameters(AudioMixer mixer)
        {
            List<string> exposedParams = new List<string>();

            // Using reflection to access the AudioMixer's ExposedParameters
            var dynMixer = new SerializedObject(mixer);
            var parameters = dynMixer.FindProperty("m_ExposedParameters");

            if (parameters != null && parameters.isArray)
            {
                for (int i = 0; i < parameters.arraySize; i++)
                {
                    var param = parameters.GetArrayElementAtIndex(i);
                    var nameProp = param.FindPropertyRelative("name");
                    if (nameProp != null)
                    {
                        exposedParams.Add(nameProp.stringValue);
                    }
                }
            }

            return exposedParams;
        }

I’m using it for a custom editor of the player settings, but you can use it for any purpose. I was able to get something like this:

9799938--1406652--upload_2024-4-27_16-13-31.png

Hope it helps!

5 Likes