/// <summary> /// Initialize the Audio Manager. /// </summary> protected virtual void Initialize(bool force) { if (s_Initialized && !force) { return; } s_Initialized = true; m_GameObject = gameObject; if (m_AudioManagerModule == null) { m_AudioManagerModule = ScriptableObject.CreateInstance <AudioManagerModule>(); } if (m_AudioManagerModule.DefaultAudioConfig == null) { m_AudioManagerModule.DefaultAudioConfig = ScriptableObject.CreateInstance <AudioConfig>(); } if (m_AudioManagerModule.DefaultAudioConfig.AudioSourcePrefab == null) { var audioSourceGameObject = new GameObject("AudioSource"); audioSourceGameObject.transform.parent = m_GameObject.transform; var audioSource = audioSourceGameObject.AddComponent <AudioSource>(); audioSource.playOnAwake = false; audioSource.spatialBlend = 1; m_AudioManagerModule.DefaultAudioConfig.AudioSourcePrefab = audioSourceGameObject; } }
/// <summary> /// Set the Audio Manager Module. /// </summary> /// <param name="audioManagerModule">The audio Manager Module to set.</param> public static void SetAudioManagerModule(AudioManagerModule audioManagerModule) { Instance.AudioManagerModule = audioManagerModule; }