/// <summary> /// Sets the normalized (Range 0-1) volume value for given volume group /// </summary> public void SetGroupVolume(VolumeGroup volumeGroup, float normalizedVolume) { bool volumeSet = audioMixer.SetFloat(volumeGroup.ToString(), NormalizedToMixerValue(normalizedVolume)); if (volumeSet) { switch (volumeGroup) { case VolumeGroup.Master: masterVolume = normalizedVolume; break; case VolumeGroup.Music: musicVolume = normalizedVolume; break; case VolumeGroup.SFX: sfxVolume = normalizedVolume; break; } } else { Debug.LogError("The AudioMixer parameter was not found"); } }
public float GetGroupVolume(VolumeGroup volumeGroup) { if (audioMixer.GetFloat(volumeGroup.ToString(), out float rawVolume)) { return(MixerValueToNormalized(rawVolume)); } else { Debug.LogError("The AudioMixer parameter was not found"); return(0f); } }