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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Audio mixer exposed parameters

Discussion in 'Audio & Video' started by PatArsenault, Jun 30, 2015.

  1. PatArsenault

    PatArsenault

    Joined:
    Jul 15, 2014
    Posts:
    2
    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
     
    Last edited: Jun 30, 2015
  2. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,302
    That's what they mean by "exposed". It means the parameters are exposed to script.

    http://docs.unity3d.com/ScriptReference/Audio.AudioMixer.GetFloat.html
    Code (csharp):
    1. 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.

    http://docs.unity3d.com/ScriptReference/Audio.AudioMixer.SetFloat.html
    Code (csharp):
    1. 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
     
    Last edited: Jun 30, 2015
  3. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    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)?
     
    Last edited: Jul 1, 2015
  4. PatArsenault

    PatArsenault

    Joined:
    Jul 15, 2014
    Posts:
    2
    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.
     
    kloot likes this.
  5. jerotas

    jerotas

    Joined:
    Sep 4, 2011
    Posts:
    5,555
    That would be useful :|
     
    kloot likes this.
  6. sh_code

    sh_code

    Joined:
    Apr 8, 2015
    Posts:
    17
    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
     
  7. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    281
    Anyone found any info in this yet?
     
  8. TinLiminal

    TinLiminal

    Joined:
    Oct 28, 2013
    Posts:
    18
    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".
     
    iancox890 and DiogoHartmann like this.
  9. Wahooney

    Wahooney

    Joined:
    Mar 8, 2010
    Posts:
    281
    We're asking for a way to find the exposed parameters via script.
     
  10. Hikiko66

    Hikiko66

    Joined:
    May 5, 2013
    Posts:
    1,302