A simple audio manager for your unity 2D projects, features:
- Persistance across scenes
- Music (looped) and sound playback (one shot)
- Caching of sound effects
How to use it
- Add the AudioManager prefab to your scene.
from within your code you can call any of the two music playback methods and one to stop the current music playing.
Audio.Manager.Instance.PlayMusic(AudioClip musicClip); Audio.Manager.Instance.PlayMusic(AudioClip musicClip, float volume, bool shouldRestart); Audio.Manager.Instance.StopMusic();
Sound effects are cached in order to keep them available if you re use them a lot. You have 2 methods to call to reproduce sound effects:
Audio.Manager.Instance.PlaySound(AudioClip soundClip); Audio.Manager.Instance.PlaySound(AudioClip musicClip, float volume);
- Singleton audio manager
- Sound loading scripts
- Unity package