"AudioMixer does not contain a definition for SetFloat". Volume slider configuration

Hi there. I´m trying to set up a simple volume slider but an unexpected error keeps popping. Here is the code.

The error says: “Type AudioMixer does not contain a definition for SetFloat, and no extension method SetFloat of type AudioMixer could be found. Are you missing an assembly reference?”

It goes attached to a slider. It´s crazy because this works perfectly fine in other projects.
I’m worried it is a bug. Does anyone have an idea what could be happening here?

I´m using Unity 2018.3 version. (It worked fine in other projects, same version). Also, I don’t think it has anything to do with the AudioMixer configuration. And the parameters are correctly exposed.

Your using UnityEngine.Audio; is grayed out up there, I just want to be sure that it’s actually really there!

Besides that you could try casting the result of your dB conversion to float, I don’t know why that would happen by maybe the * 20 causes a conversion to int that would then not match the SetFloat signature… but I wouldn’t bet too much on that!

In the end I would strongly suggest that you update your version of Unity, as 2018 is not supported anymore, in the sense that no more fixes are published for that version. 2022.3 is the ‘oldest’ version still receiving fixes as we speak.