diff --git a/Assets/Master.mixer b/Assets/Master.mixer new file mode 100644 index 0000000..4b28e29 --- /dev/null +++ b/Assets/Master.mixer @@ -0,0 +1,69 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!241 &24100000 +AudioMixerController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Master + m_OutputGroup: {fileID: 0} + m_MasterGroup: {fileID: 24300002} + m_Snapshots: + - {fileID: 24500006} + m_StartSnapshot: {fileID: 24500006} + m_SuspendThreshold: -80 + m_EnableSuspend: 1 + m_UpdateMode: 0 + m_ExposedParameters: [] + m_AudioMixerGroupViews: + - guids: + - 3040ff61b25861248a20f3b92dce8b2f + name: View + m_CurrentViewIndex: 0 + m_TargetSnapshot: {fileID: 24500006} +--- !u!243 &24300002 +AudioMixerGroupController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Master + m_AudioMixer: {fileID: 24100000} + m_GroupID: 3040ff61b25861248a20f3b92dce8b2f + m_Children: [] + m_Volume: a91398c1df0d04aef95a90980d612ecb + m_Pitch: 735e2b9e4c7099505b97e71cc13a68d6 + m_Send: 00000000000000000000000000000000 + m_Effects: + - {fileID: 24400004} + m_UserColorIndex: 0 + m_Mute: 0 + m_Solo: 0 + m_BypassEffects: 0 +--- !u!244 &24400004 +AudioMixerEffectController: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_EffectID: 6c86363194ae90edca59e8ce2e55844b + m_EffectName: Attenuation + m_MixLevel: 5fe356cb290dfad2eb70015bbf3b1034 + m_Parameters: [] + m_SendTarget: {fileID: 0} + m_EnableWetMix: 0 + m_Bypass: 0 +--- !u!245 &24500006 +AudioMixerSnapshotController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Snapshot + m_AudioMixer: {fileID: 24100000} + m_SnapshotID: 8ffb606daeece758c860460b0d5e4bef + m_FloatValues: + a91398c1df0d04aef95a90980d612ecb: 0 + m_TransitionOverrides: {} diff --git a/Assets/Master.mixer.meta b/Assets/Master.mixer.meta new file mode 100644 index 0000000..715a9b4 --- /dev/null +++ b/Assets/Master.mixer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8cf15f9ce587aa00ea29d786b6dec264 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 24100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Managers.prefab b/Assets/Prefabs/Managers.prefab index bb89f40..67d6171 100644 --- a/Assets/Prefabs/Managers.prefab +++ b/Assets/Prefabs/Managers.prefab @@ -56,6 +56,7 @@ MonoBehaviour: health: 0 startHealth: 100 CurrentNumEnemies: 0 + Volume: 10 --- !u!114 &6434302952035194364 MonoBehaviour: m_ObjectHideFlags: 0 @@ -69,6 +70,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: audioLibrary: {fileID: 11400000, guid: 33d9499f0cd319b2eab27cf0f8e39a40, type: 2} + mixer: {fileID: 24300002, guid: 8cf15f9ce587aa00ea29d786b6dec264, type: 2} + sfxMixer: {fileID: 24300002, guid: bcb05fb4c7c7e785090bc8c2705dd01d, type: 2} --- !u!114 &4575217513678934597 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/SFX.mixer b/Assets/SFX.mixer new file mode 100644 index 0000000..00b1858 --- /dev/null +++ b/Assets/SFX.mixer @@ -0,0 +1,69 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!241 &24100000 +AudioMixerController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: SFX + m_OutputGroup: {fileID: 0} + m_MasterGroup: {fileID: 24300002} + m_Snapshots: + - {fileID: 24500006} + m_StartSnapshot: {fileID: 24500006} + m_SuspendThreshold: -80 + m_EnableSuspend: 1 + m_UpdateMode: 0 + m_ExposedParameters: [] + m_AudioMixerGroupViews: + - guids: + - e77c1fa5721af59c095d9aadbf882f15 + name: View + m_CurrentViewIndex: 0 + m_TargetSnapshot: {fileID: 24500006} +--- !u!243 &24300002 +AudioMixerGroupController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Master + m_AudioMixer: {fileID: 24100000} + m_GroupID: e77c1fa5721af59c095d9aadbf882f15 + m_Children: [] + m_Volume: c8f7ce58f80ae81bbb6ef1523770f60e + m_Pitch: de41996096647d2c6bc41281e948de08 + m_Send: 00000000000000000000000000000000 + m_Effects: + - {fileID: 24400004} + m_UserColorIndex: 0 + m_Mute: 0 + m_Solo: 0 + m_BypassEffects: 0 +--- !u!244 &24400004 +AudioMixerEffectController: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_EffectID: 216dd1e46b531863cad81d42c9434f8c + m_EffectName: Attenuation + m_MixLevel: 6d6c9f86af26ae7568b3cfff1b0a5c69 + m_Parameters: [] + m_SendTarget: {fileID: 0} + m_EnableWetMix: 0 + m_Bypass: 0 +--- !u!245 &24500006 +AudioMixerSnapshotController: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Snapshot + m_AudioMixer: {fileID: 24100000} + m_SnapshotID: 9cb0ca034924554339b6f6a27c684119 + m_FloatValues: + c8f7ce58f80ae81bbb6ef1523770f60e: 20 + m_TransitionOverrides: {} diff --git a/Assets/SFX.mixer.meta b/Assets/SFX.mixer.meta new file mode 100644 index 0000000..e292b67 --- /dev/null +++ b/Assets/SFX.mixer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bcb05fb4c7c7e785090bc8c2705dd01d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 24100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index fb236f8..455c0c4 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18028352, g: 0.22571376, b: 0.30692244, a: 1} + m_IndirectSpecularColor: {r: 0.18029143, g: 0.22572419, b: 0.30693057, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: diff --git a/Assets/Scripts/Manager/AudioManager.cs b/Assets/Scripts/Manager/AudioManager.cs index 7d03ea8..913d8d4 100644 --- a/Assets/Scripts/Manager/AudioManager.cs +++ b/Assets/Scripts/Manager/AudioManager.cs @@ -3,12 +3,14 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; +using UnityEngine.Audio; public class AudioManager : MonoBehaviour { public static AudioManager Instance; public AudioLibraryObject audioLibrary; - + public AudioMixerGroup mixer; + public AudioMixerGroup sfxMixer; private void Awake() { @@ -31,21 +33,21 @@ public class AudioManager : MonoBehaviour { Debug.LogWarning(clip.name); } - return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip); + return Instance.audioLibrary.Clips.First(x => x.name.ToLower().Replace(" ", "")== nameOfClip.ToLower().Replace(" ", "")); } - public static AudioSource PlaySound(AudioClip clip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false) + public static AudioSource PlaySound(AudioClip clip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false, bool music = false) { - return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn); + return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn, music); } - public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false) + public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false, bool music = false) { AudioClip clip = FindAudioClip(nameOfClip); - return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn); + return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn, music); } - private static AudioSource PlaySoundInternal(AudioClip clip, Vector3 sourcePos, bool manuallyHandle, bool is3D, bool loop, bool fadeIn) + private static AudioSource PlaySoundInternal(AudioClip clip, Vector3 sourcePos, bool manuallyHandle, bool is3D, bool loop, bool fadeIn, bool music) { if (Instance == null) { @@ -59,6 +61,11 @@ public class AudioManager : MonoBehaviour audioSource.clip = clip; sourceObject.transform.position = sourcePos; sourceObject.transform.parent = Instance.transform; + audioSource.volume = GameManager.Instance.Volume; + if (music) + audioSource.outputAudioMixerGroup = Instance.mixer; + else + audioSource.outputAudioMixerGroup = Instance.sfxMixer; if (is3D) { diff --git a/Assets/Scripts/Manager/GameManager.cs b/Assets/Scripts/Manager/GameManager.cs index 79816b6..6fa7cbb 100644 --- a/Assets/Scripts/Manager/GameManager.cs +++ b/Assets/Scripts/Manager/GameManager.cs @@ -14,6 +14,8 @@ public class GameManager : MonoBehaviour public int CurrentNumEnemies = 0; + public float Volume = 10f; + /// /// First param: isBuildMode /// diff --git a/Assets/Scripts/Manager/MusicManager.cs b/Assets/Scripts/Manager/MusicManager.cs index 5f43264..61f40db 100644 --- a/Assets/Scripts/Manager/MusicManager.cs +++ b/Assets/Scripts/Manager/MusicManager.cs @@ -32,7 +32,7 @@ public class MusicManager : MonoBehaviour if (intensity > prevIntinsity) { - sources[intensity] = AudioManager.PlaySound(intensities[intensity], Vector3.zero, false, false, true, true); + sources[intensity] = AudioManager.PlaySound(intensities[intensity], Vector3.zero, false, false, true, true, true); } else if (intensity < prevIntinsity) {