Complete the code to declare an AudioMixer variable.
public AudioMixer [1];The variable name should be a valid identifier. audioMixer is a common and clear name for an AudioMixer variable.
Complete the code to set the volume parameter of the AudioMixer.
audioMixer.SetFloat("Volume", [1]);
The variable volume is commonly used to represent the volume level as a float.
Fix the error in the code to get the current volume from the AudioMixer.
float currentVolume; audioMixer.[1]("Volume", out currentVolume);
SetFloat instead of GetFloat.The correct method to get a float parameter from AudioMixer is GetFloat.
Fill both blanks to create a method that mutes the AudioMixer by setting volume to -80.
public void MuteAudio() {
audioMixer.[1]("Volume", [2]);
}GetFloat instead of SetFloat.To mute, we set the volume parameter to -80 decibels using SetFloat.
Fill all three blanks to create a method that adjusts volume only if the new level is above -80.
public void AdjustVolume(float newVolume) {
float currentVolume;
if (audioMixer.[1]("Volume", out currentVolume) && newVolume [2] -80f) {
audioMixer.[3]("Volume", newVolume);
}
}SetFloat instead of GetFloat in the if condition.The method GetFloat retrieves the current volume. We check if newVolume is greater than -80 before setting it with SetFloat.