├── Assets ├── Hellmade.meta └── Hellmade │ ├── Eazy Sound Manager.meta │ └── Eazy Sound Manager │ ├── Demo.meta │ ├── Demo │ ├── Audio.meta │ ├── Audio │ │ ├── 131660__bertrof__game-sound-correct.wav │ │ ├── 131660__bertrof__game-sound-correct.wav.meta │ │ ├── 33245__ljudman__grenade.wav │ │ ├── 33245__ljudman__grenade.wav.meta │ │ ├── Arcade Funk.mp3 │ │ ├── Arcade Funk.mp3.meta │ │ ├── Lounge Game1.wav │ │ └── Lounge Game1.wav.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── DemoScene.unity │ │ └── DemoScene.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── EazySoundManagerDemo.cs │ │ └── EazySoundManagerDemo.cs.meta │ ├── Textures.meta │ └── Textures │ │ ├── eazySoundDemoLogo.png │ │ └── eazySoundDemoLogo.png.meta │ ├── Docs.meta │ ├── Docs │ ├── API Reference.meta │ ├── API Reference │ │ ├── EazySoundManager-APIReference.chm │ │ └── EazySoundManager-APIReference.chm.meta │ ├── Manual.meta │ └── Manual │ │ ├── EazySoundManager-Manual.pdf │ │ └── EazySoundManager-Manual.pdf.meta │ ├── Scripts.meta │ └── Scripts │ ├── Audio.cs │ ├── Audio.cs.meta │ ├── EazySoundManager.cs │ └── EazySoundManager.cs.meta ├── LICENSE.md └── README.md /Assets/Hellmade.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82a60b434626b2940b12e1b497220b76 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4fb42df6b939d840930c0cf179baa99 3 | folderAsset: yes 4 | timeCreated: 1543570355 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 508da0fa6431761428af4f641f0b0e0f 3 | folderAsset: yes 4 | timeCreated: 1473159532 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b581a30b05e276546958c6e3e6a54b23 3 | folderAsset: yes 4 | timeCreated: 1473176251 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/131660__bertrof__game-sound-correct.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Demo/Audio/131660__bertrof__game-sound-correct.wav -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/131660__bertrof__game-sound-correct.wav.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad7c48dc9f5230d4fbf7c8e72549c148 3 | timeCreated: 1473184873 4 | licenseType: Store 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/33245__ljudman__grenade.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Demo/Audio/33245__ljudman__grenade.wav -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/33245__ljudman__grenade.wav.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 873c6c86031b9da469964d356b498f28 3 | timeCreated: 1473184862 4 | licenseType: Store 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/Arcade Funk.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Demo/Audio/Arcade Funk.mp3 -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/Arcade Funk.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 523f93e4829d858499a0283953cc18f3 3 | timeCreated: 1473176765 4 | licenseType: Store 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/Lounge Game1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Demo/Audio/Lounge Game1.wav -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Audio/Lounge Game1.wav.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: adb96177f30c01745bf992c263182ee0 3 | timeCreated: 1473176733 4 | licenseType: Store 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05d1cdfc2c8ff504fb1ecf55f33333a7 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Scenes/DemoScene.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5904fb77ed13acd40b127f39b3519386 3 | timeCreated: 1473160310 4 | licenseType: Store 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 221af500fbb2aae4cbad0485a54e0e2f 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Scripts/EazySoundManagerDemo.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | using Hellmade.Sound; 4 | 5 | public class EazySoundManagerDemo : MonoBehaviour 6 | { 7 | public EazySoundDemoAudioControls[] AudioControls; 8 | public Slider globalVolSlider; 9 | public Slider globalMusicVolSlider; 10 | public Slider globalSoundVolSlider; 11 | 12 | public GameObject test; 13 | 14 | private void Update () 15 | { 16 | // Update UI 17 | for(int i=0; i < AudioControls.Length; i++) 18 | { 19 | EazySoundDemoAudioControls audioControl = AudioControls[i]; 20 | if (audioControl.audio != null && audioControl.audio.IsPlaying) 21 | { 22 | if (audioControl.pauseButton != null) 23 | { 24 | audioControl.playButton.interactable = false; 25 | audioControl.pauseButton.interactable = true; 26 | audioControl.stopButton.interactable = true; 27 | audioControl.pausedStatusTxt.enabled = false; 28 | } 29 | } 30 | else if (audioControl.audio != null && audioControl.audio.Paused) 31 | { 32 | if (audioControl.pauseButton != null) 33 | { 34 | audioControl.playButton.interactable = true; 35 | audioControl.pauseButton.interactable = false; 36 | audioControl.stopButton.interactable = false; 37 | audioControl.pausedStatusTxt.enabled = true; 38 | } 39 | } 40 | else 41 | { 42 | if (audioControl.pauseButton != null) 43 | { 44 | audioControl.playButton.interactable = true; 45 | audioControl.pauseButton.interactable = false; 46 | audioControl.stopButton.interactable = false; 47 | audioControl.pausedStatusTxt.enabled = false; 48 | } 49 | } 50 | } 51 | } 52 | 53 | public void PlayMusic1() 54 | { 55 | EazySoundDemoAudioControls audioControl = AudioControls[0]; 56 | 57 | if (audioControl.audio == null) 58 | { 59 | int audioID = EazySoundManager.PlayMusic(audioControl.audioclip, audioControl.volumeSlider.value, true, false); 60 | AudioControls[0].audio = EazySoundManager.GetAudio(audioID); 61 | } 62 | else if (audioControl.audio != null && audioControl.audio.Paused) 63 | { 64 | audioControl.audio.Resume(); 65 | } 66 | else 67 | { 68 | audioControl.audio.Play(); 69 | } 70 | } 71 | 72 | public void PlayMusic2() 73 | { 74 | EazySoundDemoAudioControls audioControl = AudioControls[1]; 75 | 76 | if (audioControl.audio == null) 77 | { 78 | int audioID = EazySoundManager.PlayMusic(audioControl.audioclip, audioControl.volumeSlider.value, true, false); 79 | AudioControls[1].audio = EazySoundManager.GetAudio(audioID); 80 | } 81 | else if (audioControl.audio != null && audioControl.audio.Paused) 82 | { 83 | audioControl.audio.Resume(); 84 | } 85 | else 86 | { 87 | audioControl.audio.Play(); 88 | } 89 | } 90 | 91 | public void PlaySound1() 92 | { 93 | EazySoundDemoAudioControls audioControl = AudioControls[2]; 94 | int audioID = EazySoundManager.PlaySound(audioControl.audioclip, audioControl.volumeSlider.value); 95 | 96 | AudioControls[2].audio = EazySoundManager.GetAudio(audioID); 97 | } 98 | 99 | public void PlaySound2() 100 | { 101 | EazySoundDemoAudioControls audioControl = AudioControls[3]; 102 | int audioID = EazySoundManager.PlaySound(audioControl.audioclip, audioControl.volumeSlider.value); 103 | 104 | AudioControls[3].audio = EazySoundManager.GetAudio(audioID); 105 | } 106 | 107 | public void Pause(string audioControlIDStr) 108 | { 109 | int audioControlID = int.Parse(audioControlIDStr); 110 | EazySoundDemoAudioControls audioControl = AudioControls[audioControlID]; 111 | 112 | audioControl.audio.Pause(); 113 | } 114 | 115 | public void Stop(string audioControlIDStr) 116 | { 117 | int audioControlID = int.Parse(audioControlIDStr); 118 | EazySoundDemoAudioControls audioControl = AudioControls[audioControlID]; 119 | 120 | audioControl.audio.Stop(); 121 | } 122 | 123 | public void AudioVolumeChanged(string audioControlIDStr) 124 | { 125 | int audioControlID = int.Parse(audioControlIDStr); 126 | EazySoundDemoAudioControls audioControl = AudioControls[audioControlID]; 127 | 128 | if (audioControl.audio != null) 129 | { 130 | audioControl.audio.SetVolume(audioControl.volumeSlider.value, 0); 131 | } 132 | } 133 | 134 | public void GlobalVolumeChanged() 135 | { 136 | EazySoundManager.GlobalVolume = globalVolSlider.value; 137 | } 138 | 139 | public void GlobalMusicVolumeChanged() 140 | { 141 | EazySoundManager.GlobalMusicVolume = globalMusicVolSlider.value; 142 | } 143 | 144 | public void GlobalSoundVolumeChanged() 145 | { 146 | EazySoundManager.GlobalSoundsVolume = globalSoundVolSlider.value; 147 | } 148 | } 149 | 150 | [System.Serializable] 151 | public struct EazySoundDemoAudioControls 152 | { 153 | public AudioClip audioclip; 154 | public Audio audio; 155 | public Button playButton; 156 | public Button pauseButton; 157 | public Button stopButton; 158 | public Slider volumeSlider; 159 | public Text pausedStatusTxt; 160 | } 161 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Scripts/EazySoundManagerDemo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a78b5eb9bdf1e74d865fe5e12281214 3 | timeCreated: 1473175344 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66ba0e63b8604f243909a35e31567fb3 3 | folderAsset: yes 4 | timeCreated: 1473159519 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Textures/eazySoundDemoLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Demo/Textures/eazySoundDemoLogo.png -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Demo/Textures/eazySoundDemoLogo.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91fe1948f412b4343bc625cc0e92bd48 3 | timeCreated: 1473159915 4 | licenseType: Store 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 16 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 0 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 1 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 1 46 | spriteTessellationDetail: -1 47 | textureType: 8 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 1 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a1cb9d3d3dda374f88ec1f8c4310b9c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs/API Reference.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0cf4d8ed8e512a4280381c121a7c11e 3 | folderAsset: yes 4 | timeCreated: 1543580589 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs/API Reference/EazySoundManager-APIReference.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Docs/API Reference/EazySoundManager-APIReference.chm -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs/API Reference/EazySoundManager-APIReference.chm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0050e7f214aa2c343b1ecfaf9a5877a5 3 | timeCreated: 1543580589 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs/Manual.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d7d00a8ef9f90b488fd53534129a7ad 3 | folderAsset: yes 4 | timeCreated: 1543580589 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs/Manual/EazySoundManager-Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackM36/Eazy-Sound-Manager/c5be7bc6e7b3ffb20d24a22694892a27ea930f16/Assets/Hellmade/Eazy Sound Manager/Docs/Manual/EazySoundManager-Manual.pdf -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Docs/Manual/EazySoundManager-Manual.pdf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c942081f573a221439211bdb5b27b1d1 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5aa6c2b5e7d16af49affa6f150da5edb 3 | folderAsset: yes 4 | timeCreated: 1471688415 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Scripts/Audio.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Hellmade.Sound 4 | { 5 | /// 6 | /// The audio object 7 | /// 8 | public class Audio 9 | { 10 | /// 11 | /// The ID of the Audio 12 | /// 13 | public int AudioID { get; private set; } 14 | 15 | /// 16 | /// The type of the Audio 17 | /// 18 | public AudioType Type { get; private set; } 19 | 20 | /// 21 | /// Whether the audio is currently playing 22 | /// 23 | public bool IsPlaying { get; private set; } 24 | 25 | /// 26 | /// Whether the audio is paused 27 | /// 28 | public bool Paused { get; private set; } 29 | 30 | /// 31 | /// Whether the audio is stopping 32 | /// 33 | public bool Stopping { get; private set; } 34 | 35 | /// 36 | /// Whether the audio is created and updated at least once. 37 | /// 38 | public bool Activated { get; private set; } 39 | 40 | /// 41 | /// Whether the audio is currently pooled. Do not modify this value, it is specifically used by EazySoundManager. 42 | /// 43 | public bool Pooled { get; set; } 44 | 45 | /// 46 | /// The volume of the audio. Use SetVolume to change it. 47 | /// 48 | public float Volume { get; private set; } 49 | 50 | /// 51 | /// The audio source that is responsible for this audio. Do not modify the audiosource directly as it could result to unpredictable behaviour. Use the Audio class instead. 52 | /// 53 | public AudioSource AudioSource { get; private set; } 54 | 55 | /// 56 | /// The source transform of the audio. 57 | /// 58 | public Transform SourceTransform 59 | { 60 | get { return sourceTransform; } 61 | set 62 | { 63 | if(value == null) 64 | { 65 | sourceTransform = EazySoundManager.Gameobject.transform; 66 | } 67 | else 68 | { 69 | sourceTransform = value; 70 | } 71 | } 72 | } 73 | 74 | /// 75 | /// Audio clip to play/is playing 76 | /// 77 | public AudioClip Clip 78 | { 79 | get { return clip; } 80 | set 81 | { 82 | clip = value; 83 | if (AudioSource != null) 84 | { 85 | AudioSource.clip = clip; 86 | } 87 | } 88 | } 89 | 90 | /// 91 | /// Whether the audio will be lopped 92 | /// 93 | public bool Loop 94 | { 95 | get { return loop; } 96 | set 97 | { 98 | loop = value; 99 | if(AudioSource != null) 100 | { 101 | AudioSource.loop = loop; 102 | } 103 | } 104 | } 105 | 106 | /// 107 | /// Whether the audio is muted 108 | /// 109 | public bool Mute 110 | { 111 | get { return mute; } 112 | set 113 | { 114 | mute = value; 115 | if (AudioSource != null) 116 | { 117 | AudioSource.mute = mute; 118 | } 119 | } 120 | } 121 | 122 | /// 123 | /// Sets the priority of the audio 124 | /// 125 | public int Priority 126 | { 127 | get { return priority; } 128 | set 129 | { 130 | priority = Mathf.Clamp(value, 0, 256); 131 | if (AudioSource != null) 132 | { 133 | AudioSource.priority = priority; 134 | } 135 | } 136 | } 137 | 138 | /// 139 | /// The pitch of the audio 140 | /// 141 | public float Pitch 142 | { 143 | get { return pitch; } 144 | set 145 | { 146 | pitch = Mathf.Clamp(value, -3, 3); 147 | if (AudioSource != null) 148 | { 149 | AudioSource.pitch = pitch; 150 | } 151 | } 152 | } 153 | 154 | /// 155 | /// Pans a playing sound in a stereo way (left or right). This only applies to sounds that are Mono or Stereo. 156 | /// 157 | public float StereoPan 158 | { 159 | get { return stereoPan; } 160 | set 161 | { 162 | stereoPan = Mathf.Clamp(value, -1, 1); 163 | if (AudioSource != null) 164 | { 165 | AudioSource.panStereo = stereoPan; 166 | } 167 | } 168 | } 169 | 170 | /// 171 | /// Sets how much this AudioSource is affected by 3D spatialisation calculations (attenuation, doppler etc). 0.0 makes the sound full 2D, 1.0 makes it full 3D. 172 | /// 173 | public float SpatialBlend 174 | { 175 | get { return spatialBlend; } 176 | set 177 | { 178 | spatialBlend = Mathf.Clamp01(value); 179 | if (AudioSource != null) 180 | { 181 | AudioSource.spatialBlend = spatialBlend; 182 | } 183 | } 184 | } 185 | 186 | /// 187 | /// The amount by which the signal from the AudioSource will be mixed into the global reverb associated with the Reverb Zones. 188 | /// 189 | public float ReverbZoneMix 190 | { 191 | get { return reverbZoneMix; } 192 | set 193 | { 194 | reverbZoneMix = Mathf.Clamp(value, 0, 1.1f); 195 | if (AudioSource != null) 196 | { 197 | AudioSource.reverbZoneMix = reverbZoneMix; 198 | } 199 | } 200 | } 201 | 202 | /// 203 | /// The doppler scale of the audio 204 | /// 205 | public float DopplerLevel 206 | { 207 | get { return dopplerLevel; } 208 | set 209 | { 210 | dopplerLevel = Mathf.Clamp(value, 0, 5); 211 | if (AudioSource != null) 212 | { 213 | AudioSource.dopplerLevel = dopplerLevel; 214 | } 215 | } 216 | } 217 | 218 | /// 219 | /// The spread angle (in degrees) of a 3d stereo or multichannel sound in speaker space. 220 | /// 221 | public float Spread 222 | { 223 | get { return spread; } 224 | set 225 | { 226 | spread = Mathf.Clamp(value, 0, 360); 227 | if (AudioSource != null) 228 | { 229 | AudioSource.spread = spread; 230 | } 231 | } 232 | } 233 | 234 | /// 235 | /// How the audio attenuates over distance 236 | /// 237 | public AudioRolloffMode RolloffMode 238 | { 239 | get { return rolloffMode; } 240 | set 241 | { 242 | rolloffMode = value; 243 | if (AudioSource != null) 244 | { 245 | AudioSource.rolloffMode = rolloffMode; 246 | } 247 | } 248 | } 249 | 250 | /// 251 | /// (Logarithmic rolloff) MaxDistance is the distance a sound stops attenuating at. 252 | /// 253 | public float Max3DDistance 254 | { 255 | get { return max3DDistance; } 256 | set 257 | { 258 | max3DDistance = Mathf.Max(value, 0.01f); 259 | if(AudioSource != null) 260 | { 261 | AudioSource.maxDistance = max3DDistance; 262 | } 263 | } 264 | } 265 | 266 | /// 267 | /// Within the Min distance the audio will cease to grow louder in volume. 268 | /// 269 | public float Min3DDistance 270 | { 271 | get { return min3DDistance; } 272 | set 273 | { 274 | min3DDistance = Mathf.Max(value, 0); 275 | if (AudioSource != null) 276 | { 277 | AudioSource.minDistance = min3DDistance; 278 | } 279 | } 280 | } 281 | 282 | /// 283 | /// Whether the audio persists in between scene changes 284 | /// 285 | public bool Persist { get; set; } 286 | 287 | /// 288 | /// How many seconds it needs for the audio to fade in/ reach target volume (if higher than current) 289 | /// 290 | public float FadeInSeconds { get; set; } 291 | 292 | /// 293 | /// How many seconds it needs for the audio to fade out/ reach target volume (if lower than current) 294 | /// 295 | public float FadeOutSeconds { get; set; } 296 | 297 | /// 298 | /// Enum representing the type of audio 299 | /// 300 | public enum AudioType 301 | { 302 | Music, 303 | Sound, 304 | UISound 305 | } 306 | 307 | private static int audioCounter = 0; 308 | 309 | private AudioClip clip; 310 | private bool loop; 311 | private bool mute; 312 | private int priority; 313 | private float pitch; 314 | private float stereoPan; 315 | private float spatialBlend; 316 | private float reverbZoneMix; 317 | private float dopplerLevel; 318 | private float spread; 319 | private AudioRolloffMode rolloffMode; 320 | private float max3DDistance; 321 | private float min3DDistance; 322 | 323 | private float targetVolume; 324 | private float initTargetVolume; 325 | private float tempFadeSeconds; 326 | private float fadeInterpolater; 327 | private float onFadeStartVolume; 328 | private Transform sourceTransform; 329 | 330 | public Audio(AudioType audioType, AudioClip clip, bool loop, bool persist, float volume, float fadeInValue, float fadeOutValue, Transform sourceTransform) 331 | { 332 | // Set unique audio ID 333 | AudioID = audioCounter; 334 | audioCounter++; 335 | 336 | // Initialize values 337 | this.Type = audioType; 338 | this.Clip = clip; 339 | this.SourceTransform = sourceTransform; 340 | this.Loop = loop; 341 | this.Persist = persist; 342 | this.targetVolume = volume; 343 | this.initTargetVolume = volume; 344 | this.tempFadeSeconds = -1; 345 | this.FadeInSeconds = fadeInValue; 346 | this.FadeOutSeconds = fadeOutValue; 347 | 348 | Volume = 0f; 349 | Pooled = false; 350 | 351 | // Set audiosource default values 352 | Mute = false; 353 | Priority = 128; 354 | Pitch = 1; 355 | StereoPan = 0; 356 | if (sourceTransform != null && sourceTransform != EazySoundManager.Gameobject.transform) 357 | { 358 | SpatialBlend = 1; 359 | } 360 | ReverbZoneMix = 1; 361 | DopplerLevel = 1; 362 | Spread = 0; 363 | RolloffMode = AudioRolloffMode.Logarithmic; 364 | Min3DDistance = 1; 365 | Max3DDistance = 500; 366 | 367 | // Initliaze states 368 | IsPlaying = false; 369 | Paused = false; 370 | Activated = false; 371 | } 372 | 373 | /// 374 | /// Creates and initializes the audiosource component with the appropriate values 375 | /// 376 | private void CreateAudiosource() 377 | { 378 | AudioSource = SourceTransform.gameObject.AddComponent() as AudioSource; 379 | AudioSource.clip = Clip; 380 | AudioSource.loop = Loop; 381 | AudioSource.mute = Mute; 382 | AudioSource.volume = Volume; 383 | AudioSource.priority = Priority; 384 | AudioSource.pitch = Pitch; 385 | AudioSource.panStereo = StereoPan; 386 | AudioSource.spatialBlend = SpatialBlend; 387 | AudioSource.reverbZoneMix = ReverbZoneMix; 388 | AudioSource.dopplerLevel = DopplerLevel; 389 | AudioSource.spread = Spread; 390 | AudioSource.rolloffMode = RolloffMode; 391 | AudioSource.maxDistance = Max3DDistance; 392 | AudioSource.minDistance = Min3DDistance; 393 | } 394 | 395 | /// 396 | /// Start playing audio clip from the beginning 397 | /// 398 | public void Play() 399 | { 400 | Play(initTargetVolume); 401 | } 402 | 403 | /// 404 | /// Start playing audio clip from the beggining 405 | /// 406 | /// The target volume 407 | public void Play(float volume) 408 | { 409 | // Check if audio still exists in sound manager 410 | if (Pooled) 411 | { 412 | // If not, restore it from the audioPool 413 | bool restoredFromPool = EazySoundManager.RestoreAudioFromPool(Type, AudioID); 414 | if (!restoredFromPool) 415 | { 416 | return; 417 | } 418 | 419 | Pooled = true; 420 | } 421 | 422 | // Recreate audiosource if it does not exist 423 | if (AudioSource == null) 424 | { 425 | CreateAudiosource(); 426 | } 427 | 428 | AudioSource.Play(); 429 | IsPlaying = true; 430 | 431 | fadeInterpolater = 0f; 432 | onFadeStartVolume = this.Volume; 433 | targetVolume = volume; 434 | } 435 | 436 | /// 437 | /// Stop playing audio clip 438 | /// 439 | public void Stop() 440 | { 441 | fadeInterpolater = 0f; 442 | onFadeStartVolume = Volume; 443 | targetVolume = 0f; 444 | 445 | Stopping = true; 446 | } 447 | 448 | /// 449 | /// Pause playing audio clip 450 | /// 451 | public void Pause() 452 | { 453 | AudioSource.Pause(); 454 | Paused = true; 455 | } 456 | 457 | /// 458 | /// Resume playing audio clip 459 | /// 460 | public void UnPause() 461 | { 462 | AudioSource.UnPause(); 463 | Paused = false; 464 | } 465 | 466 | /// 467 | /// Resume playing audio clip 468 | /// 469 | public void Resume() 470 | { 471 | AudioSource.UnPause(); 472 | Paused = false; 473 | } 474 | 475 | /// 476 | /// Sets the audio volume 477 | /// 478 | /// The target volume 479 | public void SetVolume(float volume) 480 | { 481 | if (volume > targetVolume) 482 | { 483 | SetVolume(volume, FadeOutSeconds); 484 | } 485 | else 486 | { 487 | SetVolume(volume, FadeInSeconds); 488 | } 489 | } 490 | 491 | /// 492 | /// Sets the audio volume 493 | /// 494 | /// The target volume 495 | /// How many seconds it needs for the audio to fade in/out to reach target volume. If passed, it will override the Audio's fade in/out seconds, but only for this transition 496 | public void SetVolume(float volume, float fadeSeconds) 497 | { 498 | SetVolume(volume, fadeSeconds, this.Volume); 499 | } 500 | 501 | /// 502 | /// Sets the audio volume 503 | /// 504 | /// The target volume 505 | /// How many seconds it needs for the audio to fade in/out to reach target volume. If passed, it will override the Audio's fade in/out seconds, but only for this transition 506 | /// Immediately set the volume to this value before beginning the fade. If not passed, the Audio will start fading from the current volume towards the target volume 507 | public void SetVolume(float volume, float fadeSeconds, float startVolume) 508 | { 509 | targetVolume = Mathf.Clamp01(volume); 510 | fadeInterpolater = 0; 511 | onFadeStartVolume = startVolume; 512 | tempFadeSeconds = fadeSeconds; 513 | } 514 | 515 | /// 516 | /// Sets the Audio 3D distances 517 | /// 518 | /// the min distance 519 | /// the max distance 520 | public void Set3DDistances(float min, float max) 521 | { 522 | Min3DDistance = min; 523 | Max3DDistance = max; 524 | } 525 | 526 | /// 527 | /// Update loop of the Audio. This is automatically called from the sound manager itself. Do not use this function anywhere else, as it may lead to unwanted behaviour. 528 | /// 529 | public void Update() 530 | { 531 | if (AudioSource == null) 532 | { 533 | return; 534 | } 535 | 536 | Activated = true; 537 | 538 | // Increase/decrease volume to reach the current target 539 | if (Volume != targetVolume) 540 | { 541 | float fadeValue; 542 | fadeInterpolater += Time.unscaledDeltaTime; 543 | if (Volume > targetVolume) 544 | { 545 | fadeValue = tempFadeSeconds != -1 ? tempFadeSeconds : FadeOutSeconds; 546 | } 547 | else 548 | { 549 | fadeValue = tempFadeSeconds != -1 ? tempFadeSeconds : FadeInSeconds; 550 | } 551 | 552 | Volume = Mathf.Lerp(onFadeStartVolume, targetVolume, fadeInterpolater / fadeValue); 553 | } 554 | else if (tempFadeSeconds != -1) 555 | { 556 | tempFadeSeconds = -1; 557 | } 558 | 559 | // Set the volume, taking into account the global volumes as well. 560 | switch (Type) 561 | { 562 | case AudioType.Music: 563 | { 564 | AudioSource.volume = Volume * EazySoundManager.GlobalMusicVolume * EazySoundManager.GlobalVolume; 565 | break; 566 | } 567 | case AudioType.Sound: 568 | { 569 | AudioSource.volume = Volume * EazySoundManager.GlobalSoundsVolume * EazySoundManager.GlobalVolume; 570 | break; 571 | } 572 | case AudioType.UISound: 573 | { 574 | AudioSource.volume = Volume * EazySoundManager.GlobalUISoundsVolume * EazySoundManager.GlobalVolume; 575 | break; 576 | } 577 | } 578 | 579 | // Completely stop audio if it finished the process of stopping 580 | if (Volume == 0f && Stopping) 581 | { 582 | AudioSource.Stop(); 583 | Stopping = false; 584 | IsPlaying = false; 585 | Paused = false; 586 | } 587 | 588 | // Update playing status 589 | if (AudioSource.isPlaying != IsPlaying && Application.isFocused) 590 | { 591 | IsPlaying = AudioSource.isPlaying; 592 | } 593 | } 594 | } 595 | } -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Scripts/Audio.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb53b2b01d9c011488ad229895b665b5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Scripts/EazySoundManager.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using UnityEngine.SceneManagement; 4 | using System.Linq; 5 | 6 | namespace Hellmade.Sound 7 | { 8 | /// 9 | /// Static class responsible for playing and managing audio and sounds. 10 | /// 11 | public class EazySoundManager : MonoBehaviour 12 | { 13 | /// 14 | /// The gameobject that the sound manager is attached to 15 | /// 16 | public static GameObject Gameobject { get { return Instance.gameObject; } } 17 | 18 | /// 19 | /// When set to true, new music audios that have the same audio clip as any other music audios, will be ignored 20 | /// 21 | public static bool IgnoreDuplicateMusic { get; set; } 22 | 23 | /// 24 | /// When set to true, new sound audios that have the same audio clip as any other sound audios, will be ignored 25 | /// 26 | public static bool IgnoreDuplicateSounds { get; set; } 27 | 28 | /// 29 | /// When set to true, new UI sound audios that have the same audio clip as any other UI sound audios, will be ignored 30 | /// 31 | public static bool IgnoreDuplicateUISounds { get; set; } 32 | 33 | /// 34 | /// Global volume 35 | /// 36 | public static float GlobalVolume { get; set; } 37 | 38 | /// 39 | /// Global music volume 40 | /// 41 | public static float GlobalMusicVolume { get; set; } 42 | 43 | /// 44 | /// Global sounds volume 45 | /// 46 | public static float GlobalSoundsVolume { get; set; } 47 | 48 | /// 49 | /// Global UI sounds volume 50 | /// 51 | public static float GlobalUISoundsVolume { get; set; } 52 | 53 | private static EazySoundManager instance = null; 54 | 55 | private static Dictionary musicAudio; 56 | private static Dictionary soundsAudio; 57 | private static Dictionary UISoundsAudio; 58 | private static Dictionary audioPool; 59 | 60 | private static bool initialized = false; 61 | 62 | private static EazySoundManager Instance 63 | { 64 | get 65 | { 66 | if (instance == null) 67 | { 68 | instance = (EazySoundManager)FindObjectOfType(typeof(EazySoundManager)); 69 | if (instance == null) 70 | { 71 | // Create gameObject and add component 72 | instance = (new GameObject("EazySoundManager")).AddComponent(); 73 | } 74 | } 75 | return instance; 76 | } 77 | } 78 | 79 | static EazySoundManager() 80 | { 81 | Instance.Init(); 82 | } 83 | 84 | /// 85 | /// Initialized the sound manager 86 | /// 87 | private void Init() 88 | { 89 | if (!initialized) 90 | { 91 | musicAudio = new Dictionary(); 92 | soundsAudio = new Dictionary(); 93 | UISoundsAudio = new Dictionary(); 94 | audioPool = new Dictionary(); 95 | 96 | GlobalVolume = 1; 97 | GlobalMusicVolume = 1; 98 | GlobalSoundsVolume = 1; 99 | GlobalUISoundsVolume = 1; 100 | 101 | IgnoreDuplicateMusic = false; 102 | IgnoreDuplicateSounds = false; 103 | IgnoreDuplicateUISounds = false; 104 | 105 | initialized = true; 106 | DontDestroyOnLoad(this); 107 | } 108 | } 109 | 110 | private void OnEnable() 111 | { 112 | SceneManager.sceneLoaded += OnSceneLoaded; 113 | } 114 | 115 | private void OnDisable() 116 | { 117 | SceneManager.sceneLoaded -= OnSceneLoaded; 118 | } 119 | 120 | /// 121 | /// Event triggered when a new scene is loaded 122 | /// 123 | /// The scene that is loaded 124 | /// The scene load mode 125 | private void OnSceneLoaded(Scene scene, LoadSceneMode mode) 126 | { 127 | // Stop and remove all non-persistent audio 128 | RemoveNonPersistAudio(musicAudio); 129 | RemoveNonPersistAudio(soundsAudio); 130 | RemoveNonPersistAudio(UISoundsAudio); 131 | } 132 | 133 | private void Update() 134 | { 135 | UpdateAllAudio(musicAudio); 136 | UpdateAllAudio(soundsAudio); 137 | UpdateAllAudio(UISoundsAudio); 138 | } 139 | 140 | /// 141 | /// Retrieves the audio dictionary based on the audioType 142 | /// 143 | /// The audio type of the dictionary to return 144 | /// An audio dictionary 145 | private static Dictionary GetAudioTypeDictionary(Audio.AudioType audioType) 146 | { 147 | Dictionary audioDict = new Dictionary(); 148 | switch (audioType) 149 | { 150 | case Audio.AudioType.Music: 151 | audioDict = musicAudio; 152 | break; 153 | case Audio.AudioType.Sound: 154 | audioDict = soundsAudio; 155 | break; 156 | case Audio.AudioType.UISound: 157 | audioDict = UISoundsAudio; 158 | break; 159 | } 160 | 161 | return audioDict; 162 | } 163 | 164 | /// 165 | /// Retrieves the IgnoreDuplicates setting of audios of a specified audio type 166 | /// 167 | /// The audio type that the returned IgnoreDuplicates setting affects 168 | /// An IgnoreDuplicates setting (bool) 169 | private static bool GetAudioTypeIgnoreDuplicateSetting(Audio.AudioType audioType) 170 | { 171 | switch (audioType) 172 | { 173 | case Audio.AudioType.Music: 174 | return IgnoreDuplicateMusic; 175 | case Audio.AudioType.Sound: 176 | return IgnoreDuplicateSounds; 177 | case Audio.AudioType.UISound: 178 | return IgnoreDuplicateUISounds; 179 | default: 180 | return false; 181 | } 182 | } 183 | 184 | /// 185 | /// Updates the state of all audios of an audio dictionary 186 | /// 187 | /// The audio dictionary to update 188 | private static void UpdateAllAudio(Dictionary audioDict) 189 | { 190 | // Go through all audios and update them 191 | List keys = new List(audioDict.Keys); 192 | foreach (int key in keys) 193 | { 194 | Audio audio = audioDict[key]; 195 | audio.Update(); 196 | 197 | // Remove it if it is no longer active (playing) 198 | if (!audio.IsPlaying && !audio.Paused) 199 | { 200 | Destroy(audio.AudioSource); 201 | 202 | // Add it to the audio pool in case it needs to be referenced in the future 203 | audioPool.Add(key, audio); 204 | audio.Pooled = true; 205 | audioDict.Remove(key); 206 | } 207 | } 208 | } 209 | 210 | /// 211 | /// Remove all non-persistant audios from an audio dictionary 212 | /// 213 | /// The audio dictionary whose non-persistant audios are getting removed 214 | private static void RemoveNonPersistAudio(Dictionary audioDict) 215 | { 216 | // Go through all audios and remove them if they should not persist through scenes 217 | List keys = new List(audioDict.Keys); 218 | foreach (int key in keys) 219 | { 220 | Audio audio = audioDict[key]; 221 | if (!audio.Persist && audio.Activated) 222 | { 223 | Destroy(audio.AudioSource); 224 | audioDict.Remove(key); 225 | } 226 | } 227 | 228 | // Go through all audios in the audio pool and remove them if they should not persist through scenes 229 | keys = new List(audioPool.Keys); 230 | foreach (int key in keys) 231 | { 232 | Audio audio = audioPool[key]; 233 | if (!audio.Persist && audio.Activated) 234 | { 235 | audioPool.Remove(key); 236 | } 237 | } 238 | } 239 | 240 | /// 241 | /// Restores and re-adds a pooled audio to its corresponding audio dictionary 242 | /// 243 | /// The audio type of the audio to restore 244 | /// The ID of the audio to be restored 245 | /// True if the audio is restored, false if the audio was not in the audio pool. 246 | public static bool RestoreAudioFromPool(Audio.AudioType audioType, int audioID) 247 | { 248 | if(audioPool.ContainsKey(audioID)) 249 | { 250 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 251 | audioDict.Add(audioID, audioPool[audioID]); 252 | audioPool.Remove(audioID); 253 | 254 | return true; 255 | } 256 | 257 | return false; 258 | } 259 | 260 | #region GetAudio Functions 261 | 262 | /// 263 | /// Returns the Audio that has as its id the audioID if one is found, returns null if no such Audio is found 264 | /// 265 | /// The id of the Audio to be retrieved 266 | /// Audio that has as its id the audioID, null if no such Audio is found 267 | public static Audio GetAudio(int audioID) 268 | { 269 | Audio audio; 270 | 271 | audio = GetMusicAudio(audioID); 272 | if (audio != null) 273 | { 274 | return audio; 275 | } 276 | 277 | audio = GetSoundAudio(audioID); 278 | if (audio != null) 279 | { 280 | return audio; 281 | } 282 | 283 | audio = GetUISoundAudio(audioID); 284 | if (audio != null) 285 | { 286 | return audio; 287 | } 288 | 289 | return null; 290 | } 291 | 292 | /// 293 | /// Returns the first occurrence of Audio that plays the given audioClip. Returns null if no such Audio is found 294 | /// 295 | /// The audio clip of the Audio to be retrieved 296 | /// First occurrence of Audio that has as plays the audioClip, null if no such Audio is found 297 | public static Audio GetAudio(AudioClip audioClip) 298 | { 299 | Audio audio = GetMusicAudio(audioClip); 300 | if (audio != null) 301 | { 302 | return audio; 303 | } 304 | 305 | audio = GetSoundAudio(audioClip); 306 | if (audio != null) 307 | { 308 | return audio; 309 | } 310 | 311 | audio = GetUISoundAudio(audioClip); 312 | if (audio != null) 313 | { 314 | return audio; 315 | } 316 | 317 | return null; 318 | } 319 | 320 | /// 321 | /// Returns the music Audio that has as its id the audioID if one is found, returns null if no such Audio is found 322 | /// 323 | /// The id of the music Audio to be returned 324 | /// Music Audio that has as its id the audioID if one is found, null if no such Audio is found 325 | public static Audio GetMusicAudio(int audioID) 326 | { 327 | return GetAudio(Audio.AudioType.Music, true, audioID); 328 | } 329 | 330 | /// 331 | /// Returns the first occurrence of music Audio that plays the given audioClip. Returns null if no such Audio is found 332 | /// 333 | /// The audio clip of the music Audio to be retrieved 334 | /// First occurrence of music Audio that has as plays the audioClip, null if no such Audio is found 335 | public static Audio GetMusicAudio(AudioClip audioClip) 336 | { 337 | return GetAudio(Audio.AudioType.Music, true, audioClip); 338 | } 339 | 340 | /// 341 | /// Returns the sound fx Audio that has as its id the audioID if one is found, returns null if no such Audio is found 342 | /// 343 | /// The id of the sound fx Audio to be returned 344 | /// Sound fx Audio that has as its id the audioID if one is found, null if no such Audio is found 345 | public static Audio GetSoundAudio(int audioID) 346 | { 347 | return GetAudio(Audio.AudioType.Sound, true, audioID); 348 | } 349 | 350 | /// 351 | /// Returns the first occurrence of sound Audio that plays the given audioClip. Returns null if no such Audio is found 352 | /// 353 | /// The audio clip of the sound Audio to be retrieved 354 | /// First occurrence of sound Audio that has as plays the audioClip, null if no such Audio is found 355 | public static Audio GetSoundAudio(AudioClip audioClip) 356 | { 357 | return GetAudio(Audio.AudioType.Sound, true, audioClip); 358 | } 359 | 360 | /// 361 | /// Returns the UI sound fx Audio that has as its id the audioID if one is found, returns null if no such Audio is found 362 | /// 363 | /// The id of the UI sound fx Audio to be returned 364 | /// UI sound fx Audio that has as its id the audioID if one is found, null if no such Audio is found 365 | public static Audio GetUISoundAudio(int audioID) 366 | { 367 | return GetAudio(Audio.AudioType.UISound, true, audioID); 368 | } 369 | 370 | /// 371 | /// Returns the first occurrence of UI sound Audio that plays the given audioClip. Returns null if no such Audio is found 372 | /// 373 | /// The audio clip of the UI sound Audio to be retrieved 374 | /// First occurrence of UI sound Audio that has as plays the audioClip, null if no such Audio is found 375 | public static Audio GetUISoundAudio(AudioClip audioClip) 376 | { 377 | return GetAudio(Audio.AudioType.UISound, true, audioClip); 378 | } 379 | 380 | private static Audio GetAudio(Audio.AudioType audioType, bool usePool, int audioID) 381 | { 382 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 383 | 384 | if (audioDict.ContainsKey(audioID)) 385 | { 386 | return audioDict[audioID]; 387 | } 388 | 389 | if (usePool && audioPool.ContainsKey(audioID) && audioPool[audioID].Type == audioType) 390 | { 391 | return audioPool[audioID]; 392 | } 393 | 394 | return null; 395 | } 396 | 397 | private static Audio GetAudio(Audio.AudioType audioType, bool usePool, AudioClip audioClip) 398 | { 399 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 400 | 401 | List audioTypeKeys = new List(audioDict.Keys); 402 | List poolKeys = new List(audioPool.Keys); 403 | List keys = usePool ? audioTypeKeys.Concat(poolKeys).ToList() : audioTypeKeys; 404 | foreach (int key in keys) 405 | { 406 | Audio audio = null; 407 | if (audioDict.ContainsKey(key)) 408 | { 409 | audio = audioDict[key]; 410 | } 411 | else if(audioPool.ContainsKey(key)) 412 | { 413 | audio = audioPool[key]; 414 | } 415 | if (audio == null) 416 | { 417 | return null; 418 | } 419 | if (audio.Clip == audioClip && audio.Type == audioType) 420 | { 421 | return audio; 422 | } 423 | } 424 | 425 | return null; 426 | } 427 | 428 | #endregion 429 | 430 | #region Prepare Function 431 | 432 | /// 433 | /// Prepares and initializes background music 434 | /// 435 | /// The audio clip to prepare 436 | /// The ID of the created Audio object 437 | public static int PrepareMusic(AudioClip clip) 438 | { 439 | return PrepareAudio(Audio.AudioType.Music, clip, 1f, false, false, 1f, 1f, -1f, null); 440 | } 441 | 442 | /// 443 | /// Prepares and initializes background music 444 | /// 445 | /// The audio clip to prepare 446 | /// The volume the music will have 447 | /// The ID of the created Audio object 448 | public static int PrepareMusic(AudioClip clip, float volume) 449 | { 450 | return PrepareAudio(Audio.AudioType.Music, clip, volume, false, false, 1f, 1f, -1f, null); 451 | } 452 | 453 | /// 454 | /// Prepares and initializes background music 455 | /// 456 | /// The audio clip to prepare 457 | /// The volume the music will have 458 | /// Wether the music is looped 459 | /// Whether the audio persists in between scene changes 460 | /// The ID of the created Audio object 461 | public static int PrepareMusic(AudioClip clip, float volume, bool loop, bool persist) 462 | { 463 | return PrepareAudio(Audio.AudioType.Music, clip, volume, loop, persist, 1f, 1f, -1f, null); 464 | } 465 | 466 | /// 467 | /// Prerpares and initializes background music 468 | /// 469 | /// The audio clip to prepare 470 | /// The volume the music will have 471 | /// Wether the music is looped 472 | /// Whether the audio persists in between scene changes 473 | /// How many seconds it needs for the audio to fade in/ reach target volume (if higher than current) 474 | /// How many seconds it needs for the audio to fade out/ reach target volume (if lower than current) 475 | /// The ID of the created Audio object 476 | public static int PrepareMusic(AudioClip clip, float volume, bool loop, bool persist, float fadeInSeconds, float fadeOutSeconds) 477 | { 478 | return PrepareAudio(Audio.AudioType.Music, clip, volume, loop, persist, fadeInSeconds, fadeOutSeconds, -1f, null); 479 | } 480 | 481 | /// 482 | /// Prepares and initializes background music 483 | /// 484 | /// The audio clip to prepare 485 | /// The volume the music will have 486 | /// Wether the music is looped 487 | /// Whether the audio persists in between scene changes 488 | /// How many seconds it needs for the audio to fade in/ reach target volume (if higher than current) 489 | /// How many seconds it needs for the audio to fade out/ reach target volume (if lower than current) 490 | /// How many seconds it needs for current music audio to fade out. It will override its own fade out seconds. If -1 is passed, current music will keep its own fade out seconds 491 | /// The transform that is the source of the music (will become 3D audio). If 3D audio is not wanted, use null 492 | /// The ID of the created Audio object 493 | public static int PrepareMusic(AudioClip clip, float volume, bool loop, bool persist, float fadeInSeconds, float fadeOutSeconds, float currentMusicfadeOutSeconds, Transform sourceTransform) 494 | { 495 | return PrepareAudio(Audio.AudioType.Music, clip, volume, loop, persist, fadeInSeconds, fadeOutSeconds, currentMusicfadeOutSeconds, sourceTransform); 496 | } 497 | 498 | /// 499 | /// Prepares and initializes a sound fx 500 | /// 501 | /// The audio clip to prepare 502 | /// The ID of the created Audio object 503 | public static int PrepareSound(AudioClip clip) 504 | { 505 | return PrepareAudio(Audio.AudioType.Sound, clip, 1f, false, false, 0f, 0f, -1f, null); 506 | } 507 | 508 | /// 509 | /// Prepares and initializes a sound fx 510 | /// 511 | /// The audio clip to prepare 512 | /// The volume the music will have 513 | /// The ID of the created Audio object 514 | public static int PrepareSound(AudioClip clip, float volume) 515 | { 516 | return PrepareAudio(Audio.AudioType.Sound, clip, volume, false, false, 0f, 0f, -1f, null); 517 | } 518 | 519 | /// 520 | /// Prepares and initializes a sound fx 521 | /// 522 | /// The audio clip to prepare 523 | /// Wether the sound is looped 524 | /// The ID of the created Audio object 525 | public static int PrepareSound(AudioClip clip, bool loop) 526 | { 527 | return PrepareAudio(Audio.AudioType.Sound, clip, 1f, loop, false, 0f, 0f, -1f, null); 528 | } 529 | 530 | /// 531 | /// Prepares and initializes a sound fx 532 | /// 533 | /// The audio clip to prepare 534 | /// The volume the music will have 535 | /// Wether the sound is looped 536 | /// The transform that is the source of the sound (will become 3D audio). If 3D audio is not wanted, use null 537 | /// The ID of the created Audio object 538 | public static int PrepareSound(AudioClip clip, float volume, bool loop, Transform sourceTransform) 539 | { 540 | return PrepareAudio(Audio.AudioType.Sound, clip, volume, loop, false, 0f, 0f, -1f, sourceTransform); 541 | } 542 | 543 | /// 544 | /// Prepares and initializes a UI sound fx 545 | /// 546 | /// The audio clip to prepare 547 | /// The ID of the created Audio object 548 | public static int PrepareUISound(AudioClip clip) 549 | { 550 | return PrepareAudio(Audio.AudioType.UISound, clip, 1f, false, false, 0f, 0f, -1f, null); 551 | } 552 | 553 | /// 554 | /// Prepares and initializes a UI sound fx 555 | /// 556 | /// The audio clip to prepare 557 | /// The volume the music will have 558 | /// The ID of the created Audio object 559 | public static int PrepareUISound(AudioClip clip, float volume) 560 | { 561 | return PrepareAudio(Audio.AudioType.UISound, clip, volume, false, false, 0f, 0f, -1f, null); 562 | } 563 | 564 | private static int PrepareAudio(Audio.AudioType audioType, AudioClip clip, float volume, bool loop, bool persist, float fadeInSeconds, float fadeOutSeconds, float currentMusicfadeOutSeconds, Transform sourceTransform) 565 | { 566 | if (clip == null) 567 | { 568 | Debug.LogError("[Eazy Sound Manager] Audio clip is null", clip); 569 | } 570 | 571 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 572 | bool ignoreDuplicateAudio = GetAudioTypeIgnoreDuplicateSetting(audioType); 573 | 574 | if (ignoreDuplicateAudio) 575 | { 576 | Audio duplicateAudio = GetAudio(audioType, true, clip); 577 | if(duplicateAudio != null) 578 | { 579 | return duplicateAudio.AudioID; 580 | } 581 | } 582 | 583 | // Create the audioSource 584 | Audio audio = new Audio(audioType, clip, loop, persist, volume, fadeInSeconds, fadeOutSeconds, sourceTransform); 585 | 586 | // Add it to dictionary 587 | audioDict.Add(audio.AudioID, audio); 588 | 589 | return audio.AudioID; 590 | } 591 | 592 | #endregion 593 | 594 | #region Play Functions 595 | 596 | /// 597 | /// Play background music 598 | /// 599 | /// The audio clip to play 600 | /// The ID of the created Audio object 601 | public static int PlayMusic(AudioClip clip) 602 | { 603 | return PlayAudio(Audio.AudioType.Music, clip, 1f, false, false, 1f, 1f, -1f, null); 604 | } 605 | 606 | /// 607 | /// Play background music 608 | /// 609 | /// The audio clip to play 610 | /// The volume the music will have 611 | /// The ID of the created Audio object 612 | public static int PlayMusic(AudioClip clip, float volume) 613 | { 614 | return PlayAudio(Audio.AudioType.Music, clip, volume, false, false, 1f, 1f, -1f, null); 615 | } 616 | 617 | /// 618 | /// Play background music 619 | /// 620 | /// The audio clip to play 621 | /// The volume the music will have 622 | /// Wether the music is looped 623 | /// Whether the audio persists in between scene changes 624 | /// The ID of the created Audio object 625 | public static int PlayMusic(AudioClip clip, float volume, bool loop, bool persist) 626 | { 627 | return PlayAudio(Audio.AudioType.Music, clip, volume, loop, persist, 1f, 1f, -1f, null); 628 | } 629 | 630 | /// 631 | /// Play background music 632 | /// 633 | /// The audio clip to play 634 | /// The volume the music will have 635 | /// Wether the music is looped 636 | /// Whether the audio persists in between scene changes 637 | /// How many seconds it needs for the audio to fade in/ reach target volume (if higher than current) 638 | /// How many seconds it needs for the audio to fade out/ reach target volume (if lower than current) 639 | /// The ID of the created Audio object 640 | public static int PlayMusic(AudioClip clip, float volume, bool loop, bool persist, float fadeInSeconds, float fadeOutSeconds) 641 | { 642 | return PlayAudio(Audio.AudioType.Music, clip, volume, loop, persist, fadeInSeconds, fadeOutSeconds, -1f, null); 643 | } 644 | 645 | /// 646 | /// Play background music 647 | /// 648 | /// The audio clip to play 649 | /// The volume the music will have 650 | /// Wether the music is looped 651 | /// Whether the audio persists in between scene changes 652 | /// How many seconds it needs for the audio to fade in/ reach target volume (if higher than current) 653 | /// How many seconds it needs for the audio to fade out/ reach target volume (if lower than current) 654 | /// How many seconds it needs for current music audio to fade out. It will override its own fade out seconds. If -1 is passed, current music will keep its own fade out seconds 655 | /// The transform that is the source of the music (will become 3D audio). If 3D audio is not wanted, use null 656 | /// The ID of the created Audio object 657 | public static int PlayMusic(AudioClip clip, float volume, bool loop, bool persist, float fadeInSeconds, float fadeOutSeconds, float currentMusicfadeOutSeconds, Transform sourceTransform) 658 | { 659 | return PlayAudio(Audio.AudioType.Music, clip, volume, loop, persist, fadeInSeconds, fadeOutSeconds, currentMusicfadeOutSeconds, sourceTransform); 660 | } 661 | 662 | /// 663 | /// Play a sound fx 664 | /// 665 | /// The audio clip to play 666 | /// The ID of the created Audio object 667 | public static int PlaySound(AudioClip clip) 668 | { 669 | return PlayAudio(Audio.AudioType.Sound, clip, 1f, false, false, 0f, 0f, -1f, null); 670 | } 671 | 672 | /// 673 | /// Play a sound fx 674 | /// 675 | /// The audio clip to play 676 | /// The volume the music will have 677 | /// The ID of the created Audio object 678 | public static int PlaySound(AudioClip clip, float volume) 679 | { 680 | return PlayAudio(Audio.AudioType.Sound, clip, volume, false, false, 0f, 0f, -1f, null); 681 | } 682 | 683 | /// 684 | /// Play a sound fx 685 | /// 686 | /// The audio clip to play 687 | /// Wether the sound is looped 688 | /// The ID of the created Audio object 689 | public static int PlaySound(AudioClip clip, bool loop) 690 | { 691 | return PlayAudio(Audio.AudioType.Sound, clip, 1f, loop, false, 0f, 0f, -1f, null); 692 | } 693 | 694 | /// 695 | /// Play a sound fx 696 | /// 697 | /// The audio clip to play 698 | /// The volume the music will have 699 | /// Wether the sound is looped 700 | /// The transform that is the source of the sound (will become 3D audio). If 3D audio is not wanted, use null 701 | /// The ID of the created Audio object 702 | public static int PlaySound(AudioClip clip, float volume, bool loop, Transform sourceTransform) 703 | { 704 | return PlayAudio(Audio.AudioType.Sound, clip, volume, loop, false, 0f, 0f, -1f, sourceTransform); 705 | } 706 | 707 | /// 708 | /// Play a UI sound fx 709 | /// 710 | /// The audio clip to play 711 | /// The ID of the created Audio object 712 | public static int PlayUISound(AudioClip clip) 713 | { 714 | return PlayAudio(Audio.AudioType.UISound, clip, 1f, false, false, 0f, 0f, -1f, null); 715 | } 716 | 717 | /// 718 | /// Play a UI sound fx 719 | /// 720 | /// The audio clip to play 721 | /// The volume the music will have 722 | /// The ID of the created Audio object 723 | public static int PlayUISound(AudioClip clip, float volume) 724 | { 725 | return PlayAudio(Audio.AudioType.UISound, clip, volume, false, false, 0f, 0f, -1f, null); 726 | } 727 | 728 | private static int PlayAudio(Audio.AudioType audioType, AudioClip clip, float volume, bool loop, bool persist, float fadeInSeconds, float fadeOutSeconds, float currentMusicfadeOutSeconds, Transform sourceTransform) 729 | { 730 | int audioID = PrepareAudio(audioType, clip, volume, loop, persist, fadeInSeconds, fadeOutSeconds, currentMusicfadeOutSeconds, sourceTransform); 731 | 732 | // Stop all current music playing 733 | if (audioType == Audio.AudioType.Music) 734 | { 735 | StopAllMusic(currentMusicfadeOutSeconds); 736 | } 737 | 738 | GetAudio(audioType, false, audioID).Play(); 739 | 740 | return audioID; 741 | } 742 | 743 | #endregion 744 | 745 | #region Stop Functions 746 | 747 | /// 748 | /// Stop all audio playing 749 | /// 750 | public static void StopAll() 751 | { 752 | StopAll(-1f); 753 | } 754 | 755 | /// 756 | /// Stop all audio playing 757 | /// 758 | /// How many seconds it needs for all music audio to fade out. It will override their own fade out seconds. If -1 is passed, all music will keep their own fade out seconds 759 | public static void StopAll(float musicFadeOutSeconds) 760 | { 761 | StopAllMusic(musicFadeOutSeconds); 762 | StopAllSounds(); 763 | StopAllUISounds(); 764 | } 765 | 766 | /// 767 | /// Stop all music playing 768 | /// 769 | public static void StopAllMusic() 770 | { 771 | StopAllAudio(Audio.AudioType.Music, -1f); 772 | } 773 | 774 | /// 775 | /// Stop all music playing 776 | /// 777 | /// How many seconds it needs for all music audio to fade out. It will override their own fade out seconds. If -1 is passed, all music will keep their own fade out seconds 778 | public static void StopAllMusic(float fadeOutSeconds) 779 | { 780 | StopAllAudio(Audio.AudioType.Music, fadeOutSeconds); 781 | } 782 | 783 | /// 784 | /// Stop all sound fx playing 785 | /// 786 | public static void StopAllSounds() 787 | { 788 | StopAllAudio(Audio.AudioType.Sound, -1f); 789 | } 790 | 791 | /// 792 | /// Stop all UI sound fx playing 793 | /// 794 | public static void StopAllUISounds() 795 | { 796 | StopAllAudio(Audio.AudioType.UISound, -1f); 797 | } 798 | 799 | private static void StopAllAudio(Audio.AudioType audioType, float fadeOutSeconds) 800 | { 801 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 802 | 803 | List keys = new List(audioDict.Keys); 804 | foreach (int key in keys) 805 | { 806 | Audio audio = audioDict[key]; 807 | if (fadeOutSeconds > 0) 808 | { 809 | audio.FadeOutSeconds = fadeOutSeconds; 810 | } 811 | audio.Stop(); 812 | } 813 | } 814 | 815 | #endregion 816 | 817 | #region Pause Functions 818 | 819 | /// 820 | /// Pause all audio playing 821 | /// 822 | public static void PauseAll() 823 | { 824 | PauseAllMusic(); 825 | PauseAllSounds(); 826 | PauseAllUISounds(); 827 | } 828 | 829 | /// 830 | /// Pause all music playing 831 | /// 832 | public static void PauseAllMusic() 833 | { 834 | PauseAllAudio(Audio.AudioType.Music); 835 | } 836 | 837 | /// 838 | /// Pause all sound fx playing 839 | /// 840 | public static void PauseAllSounds() 841 | { 842 | PauseAllAudio(Audio.AudioType.Sound); 843 | } 844 | 845 | /// 846 | /// Pause all UI sound fx playing 847 | /// 848 | public static void PauseAllUISounds() 849 | { 850 | PauseAllAudio(Audio.AudioType.UISound); 851 | } 852 | 853 | private static void PauseAllAudio(Audio.AudioType audioType) 854 | { 855 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 856 | 857 | List keys = new List(audioDict.Keys); 858 | foreach (int key in keys) 859 | { 860 | Audio audio = audioDict[key]; 861 | audio.Pause(); 862 | } 863 | } 864 | 865 | #endregion 866 | 867 | #region Resume Functions 868 | 869 | /// 870 | /// Resume all audio playing 871 | /// 872 | public static void ResumeAll() 873 | { 874 | ResumeAllMusic(); 875 | ResumeAllSounds(); 876 | ResumeAllUISounds(); 877 | } 878 | 879 | /// 880 | /// Resume all music playing 881 | /// 882 | public static void ResumeAllMusic() 883 | { 884 | ResumeAllAudio(Audio.AudioType.Music); 885 | } 886 | 887 | /// 888 | /// Resume all sound fx playing 889 | /// 890 | public static void ResumeAllSounds() 891 | { 892 | ResumeAllAudio(Audio.AudioType.Sound); 893 | } 894 | 895 | /// 896 | /// Resume all UI sound fx playing 897 | /// 898 | public static void ResumeAllUISounds() 899 | { 900 | ResumeAllAudio(Audio.AudioType.UISound); 901 | } 902 | 903 | private static void ResumeAllAudio(Audio.AudioType audioType) 904 | { 905 | Dictionary audioDict = GetAudioTypeDictionary(audioType); 906 | 907 | List keys = new List(audioDict.Keys); 908 | foreach (int key in keys) 909 | { 910 | Audio audio = audioDict[key]; 911 | audio.Resume(); 912 | } 913 | } 914 | 915 | #endregion 916 | } 917 | } 918 | -------------------------------------------------------------------------------- /Assets/Hellmade/Eazy Sound Manager/Scripts/EazySoundManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0500072cba35d4749ad862e7730ad14b 3 | timeCreated: 1471688400 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Hellmade Games 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Eazy Sound Manager](https://i.imgur.com/0Hlqloi.png) 2 | [![MIT license](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://lbesson.mit-license.org/) 3 | ![](https://img.shields.io/badge/unity-5.6%2B-green.svg?style=flat-square) 4 | [![GitHub release](https://img.shields.io/github/release/JackM36/Eazy-Sound-Manager/all.svg?style=flat-square)](https://github.com/JackM36/Eazy-Sound-Manager/releases) 5 | [![Github downloads](https://img.shields.io/github/downloads/JackM36/Eazy-Sound-Manager/total.svg?style=flat-square)](https://github.com/JackM36/Eazy-Sound-Manager/releases) 6 | [![HitCount](http://hits.dwyl.io/jackm36/Eazy-Sound-Manager.svg)](http://hits.dwyl.io/jackm36/Eazy-Sound-Manager) 7 | 8 | **Eazy Sound Manager** is a simple **Unity3D tool** which aims to make sound and music management in games easier. Playing a single audio clip is now as easy as calling one API function. The API can handle multiple music, game and UI sound effects at the same time while still giving you the option to interrupt previous audio clips when needed. Audio clips can be one shot, or looping. 9 | 10 | Moreover, Eazy Sound Manager has the option to make music persist through multiple scenes, as well as add fade in/out transitions. Different global settings for music, game sound effects and UI sound effects are also implemented. However, each audio has its own volume setting which is always relative to its global volume. 11 | 12 | ## Features 13 | - Play multiple audio clips 14 | - Play music, game sound effects and UI sound effects 15 | - Play/Stop/Pause/Resume all or individual audio clips 16 | - Loop music 17 | - Fade in and fade out transitions 18 | - Global volume settings 19 | - Music persistence across scenes 20 | - 2D & 3D (spatial) audio support 21 | - Audio pooling 22 | - Runtime API (Fully documented) 23 | - No setup needed 24 | - Full C# source code 25 | 26 | ## Installation 27 | Download and put the Hellmade folder in your Assets folder, or download and import the [unity package](https://github.com/JackM36/Eazy-Sound-Manager/releases). 28 | 29 | ## Usage 30 | Read the [Getting Started Manual](http://www.hellmadegames.com/Projects/eazy-sound-manager/docs/manual/Manual.pdf) for intructions on how to setup and use Eazy Sound Manager. 31 | Read the [API Reference](http://www.hellmadegames.com/projects/eazy-sound-manager/docs/api-reference) for further details on using the API. 32 | 33 | ## Donate 34 | Eazy Sound Manager is a free asset done in my free time. However, donations helps me improve it, as well as develop and publish more projects like this. 35 | 36 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GGTKA37Z7TBTE) 37 | 38 | ## License 39 | MIT License. Copyright 2018 Hellmade Games. 40 | --------------------------------------------------------------------------------