Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

AudioMixer SetFloat initialization problem (beta17)

Discussion in 'Unity 5 Pre-order Beta' started by Capn_Andy, Dec 16, 2014.

  1. Capn_Andy

    Capn_Andy

    Joined:
    Nov 20, 2013
    Posts:
    80
    Heya! Ran into a weird glitch. checkout this code:

    Code (CSharp):
    1.         float volumeSetting = 0; // 0...1
    2.         float vol = (volumeSetting * 80) - 80; // convert to DB
    3.         musicChannel.audioMixer.SetFloat("musicVol", vol);
    4.         float val = 666;
    5.         musicChannel.audioMixer.GetFloat("musicVol", out val);
    6.         Debug.Log("setting music to "+vol+" ("+val+")");
    This outputs:
    Code (CSharp):
    1. // setting music to -80 (-0.102)
    So my problem is that GetFloat isn't returning the value that Setfloat created, which is very strange.

    Furthermore,

    If this script runs on the very first frame (initialization/Awake phase), the musicChannel in the Editor shows a net change of zero (it remains at the default of 0 db).

    If this script runs on a later frame, the Editor shows the correct value (in this case, -80), but the GetFloat still returns -0.102.

    Am I doing something really wrong or is this a bug?