/// <summary> /// constructor /// </summary> /// <param name="audioComponent">an audio component which houses the relevent audio elements</param> public AudioManager(AudioComponent audioComponent) { // assign references to all the relevant audio elements m_audioMixer = audioComponent.GetAudioMixer(); m_BGM = audioComponent.GetBGM(); m_ambience = audioComponent.GetAmbience(); m_SFX = audioComponent.GetSFX(); m_voice = audioComponent.GetVoice(); // create a new object to house each different type of audio source m_bgmAudio = new GameObject("BGM"); m_ambientAudio = new GameObject("Ambience"); m_sfxAudio = new GameObject("SFX"); m_voiceAudio = new GameObject("Voice"); // BGM, SFX and voice object all only need one AudioSource AudioSource bgmSource = m_bgmAudio.AddComponent <AudioSource>(); AudioSource sfxSource = m_sfxAudio.AddComponent <AudioSource>(); AudioSource voiceSource = m_voiceAudio.AddComponent <AudioSource>(); bgmSource.outputAudioMixerGroup = m_BGM; sfxSource.outputAudioMixerGroup = m_SFX; voiceSource.outputAudioMixerGroup = m_voice; bgmSource.loop = true; // loop the BGM }
public AudioManager(AudioComponent audioComponent) { m_audioMixer = audioComponent.GetAudioMixer(); m_BGM = audioComponent.GetBGM(); m_ambience = audioComponent.GetAmbience(); m_SFX = audioComponent.GetSFX(); m_voice = audioComponent.GetVoice(); m_bgmAudio = new GameObject("BGM"); m_ambientAudio = new GameObject("Ambience"); m_sfxAudio = new GameObject("SFX"); m_voiceAudio = new GameObject("Voice"); AudioSource bgmSource = m_bgmAudio.AddComponent <AudioSource>(); AudioSource sfxSource = m_sfxAudio.AddComponent <AudioSource>(); AudioSource voiceSource = m_voiceAudio.AddComponent <AudioSource>(); bgmSource.outputAudioMixerGroup = m_BGM; sfxSource.outputAudioMixerGroup = m_SFX; voiceSource.outputAudioMixerGroup = m_voice; bgmSource.loop = true; }