Music Manager allows you to easily play, pause and stop musics in your game with a single line of code.
Because of this, you just have to import the package in Unity and you are ready to go.
Fades and volume changes are smoothed using a cubic function :
- Docs/ - Folder containing the documentation
- MusicManager.cs - The main script
- MusicPlayer.cs - Internal script which plays the music
- Example.unity - A demo scene of the package
- ExampleScript.cs - The script for the demo
- Resources/ - Contains two musics for the demo
Here are some examples:
MusicManager.play("Dark Descent", 5.0f, 5.0f);
// Will play "The Dark Amulet.ogg" in 4s (3s fade out and 1s fade in)
MusicManager.play("The Dark Amulet", 3.0f, 1.0f);
// Pause and unpause the music
// Smoothly stop the music over 3 seconds
// Set the volume of the music to 25% immediatly
// Smoothly set the volume of the music to 100% in 1 second
// Advanced use: Access the audio component of the internal MusicManager object
GameObject player = MusicManager.getMusicEmitter();
int volume = player.audio.volume;
Will play the music after fading out the precedent music in fadeOut seconds and fading in the new music in fadeIn seconds.
Convenient function which loads the music from a Resources folder by its filename.
Set if the music should loop or not. Default is true.
Pause the music.
Unpause the music.
Stop the music over fadeOut seconds.
Set the music volume over duration seconds.
Return the GameObject containing the Audio Source of the music.
« My music is not playing! »
Make sure that your music is not set to 3D sound:
Also, if you used the string version of the play() function, make sure you are correctly pointing to the music file.
If your music is in
Assets/Subfolder/Resources/Musics/supermusic.ogg, you should pass
Musics/supermusic as the parameter.
When the music is not found, a debug message is supposed to be shown in your console.