Game Development Reference
In-Depth Information
public void SetAudioType(string SpeakerMode)
{
switch(SpeakerMode)
{
case "Mono":
AudioSettings.speakerMode =
AudioSpeakerMode.Mono;
break;
case "Stereo":
AudioSettings.speakerMode =
AudioSpeakerMode.Stereo;
break;
case "Surround":
AudioSettings.speakerMode =
AudioSpeakerMode.Surround;
break;
case "Surround 5.1":
AudioSettings.speakerMode =
AudioSpeakerMode.Mode5point1;
break;
case "Surround 7.1":
AudioSettings.speakerMode =
AudioSpeakerMode.Mode7point1;
break;
}
}
For this function, we pass a string, which will be used in a
switch
statement to
change the speaker mode. In this
switch
statement, we check for each of the
speaker modes that we want to support for our game. To change the speaker mode,
we assign the
speakerMode
variable from
AudioSettings
and assign it to the as-
sociating speaker mode.