Unity version: 2022.3.5f1
I am using sliders to change audio levels of subgroups of audiomixer. This was working fine in the editor and windows builds but I recently realized that this does not work on mobile. I have a logcat output like this:
2023.09.09 12:35:08.159 16293 16331 Warn Unity Exposed name does not exist: SFX (UnityEngine.AudioMixerGroup)
And the screenshot of my exposed parameter:
Ekran-g-r-nt-s-2023-09-09-123813 hosted at ImgBB — ImgBB
Here is the code i am using for setting volume.
static AudioManager s_AudioManager;
static AudioUtility()
{
s_AudioManager = GameObject.FindObjectOfType<AudioManager>();
}
public enum AudioGroups
{
Master,
Music,
Ambient,
SFX,
UI
}
public static AudioMixerGroup GetAudioGroup(AudioGroups group)
{
if(s_AudioManager == null) s_AudioManager = GameObject.FindObjectOfType<AudioManager>();
var groups = s_AudioManager.FindMatchingGroups(group.ToString());
if (groups.Length > 0)
return groups[0];
Debug.LogWarning("Didn't find audio group for " + group.ToString());
return null;
}
public static void SetVolume(AudioGroups audioGroup, float value)
{
if (s_AudioManager == null) s_AudioManager = GameObject.FindObjectOfType<AudioManager>();
AudioMixerGroup group = GetAudioGroup(audioGroup);
float clampedVal = Mathf.InverseLerp(100, 0, value);
clampedVal *= -80f;
s_AudioManager.SetFloat(group.ToString(), clampedVal);
}
And this is Setfloat function in the s_AudioManager
public void SetFloat(string name, float value)
{
for (int i = 0; i < AudioMixers.Length; i++)
{
if (AudioMixers[i] != null)
{
AudioMixers[i].SetFloat(name, value);
}
}
}
And there is only one AudioMixer in the project.
When I searched the internet i have came across with a guy had the same issue but he was using addressable where I don’t. So the problem is not related to that.
I also need to mention when i do this for “Master” it works. So the problem is only related to subgroups.
I started to think that this is a bug. Is there anyone can help?