This component allows the user to adjust the volume of music, or (if enabled by you) select from one of 3 musical sets. It provides generic music handling functionality. For global in-game music, add this component to an object and add a ’Persistent’ component, to prevent it from being destroyed when the scene changes. Alternatively, add a different one to each scene for varied music from scene-to-scene.
To create a speaker playing music, use this component without the ’Persistent’ component, and set the ’Spatial Blend’ setting on the ’Audio Source’ all the way to ’3D’.
AudioClip
startSplashSoundIf supplied, play this before the first track
float
musicVolumeA modifier applied to music globally
Default value: 0.8f
Slider
volumeSliderA UGUI slider for volume control. Works on all platforms.
bool
enableMusicShould the music play now?
Default value: true
bool
showGuiShould we show the legacy Unity GUI? Not suitable for mobile.
Default value: false
Rect
audioGUINormalized viewport rectangle representing the are the GUI is drawn in, numbers between 0 and 1
Default value: new Rect(0.01f, 0.01f, 0.3f, 0.4f)
MusicCategories
musicCategoryWhat is the default category of music?
Default value: MusicCategories.One
bool
allowExtraCategoriesAllow the user to select from one of the other categories, or just use one? If false, only the first category is used.
Default value: true
AudioClip[]
category1List of all songs, in order, in the category
AudioClip[]
category2List of all songs, in order, in the category
AudioClip[]
category3List of all songs, in order, in the category
float
fadeLevelIf we fade the music, how low should we fade it?
Default value: .06f
float
fadeDurationHow long from the start of the fade does it take to transition?
Default value: 3f
bool
instantStartShould we cut to low volume and then fade back? If false, we will fade out smoothly
Default value: true
Toggles the legacy Unity GUI for music control.
Turns the music on/off
Allows you to change the music category directly
Argument: The category (1, 2 or 3) of music we wish to select
Enable the legacy GUI
Disable the legacy GUI
Toggle the legacy GUI
Changes the volume just for the MusicManager
Fades the current song out smoothly
Fades in the current song smoothly
Fades the music out over a specified amount of time by setting the fade duration
Argument: The amount of time we want the fade to take
Fades the music in over a specified amount of time
Argument: How long we want the fade to take
Plays the song you want from the current category.
Argument: The index of the song you want to play. Indices start at 0 (not 1) so the first song is index 0, second is index 1 etc.
Plays the song you want from the current category, and loops it continuously.
Argument: The index of the song you want to play. Indices start at 0 (not 1) so the first song is index 0, second is index 1 etc.
AudioClip
startSplashSoundIf supplied, play this before the first track
float
musicVolumeA modifier applied to music globally
Default value: 0.8f
Slider
volumeSliderA UGUI slider for volume control. Works on all platforms.
bool
enableMusicShould the music play now?
Default value: true
bool
showGuiShould we show the legacy Unity GUI? Not suitable for mobile.
Default value: false
Rect
audioGUINormalized viewport rectangle representing the are the GUI is drawn in, numbers between 0 and 1
Default value: new Rect(0.01f, 0.01f, 0.3f, 0.4f)
MusicCategories
musicCategoryWhat is the default category of music?
Default value: MusicCategories.One
bool
allowExtraCategoriesAllow the user to select from one of the other categories, or just use one? If false, only the first category is used.
Default value: true
AudioClip[]
category1List of all songs, in order, in the category
AudioClip[]
category2List of all songs, in order, in the category
AudioClip[]
category3List of all songs, in order, in the category
float
fadeLevelIf we fade the music, how low should we fade it?
Default value: .06f
float
fadeDurationHow long from the start of the fade does it take to transition?
Default value: 3f
bool
instantStartShould we cut to low volume and then fade back? If false, we will fade out smoothly
Default value: true
Toggles the legacy Unity GUI for music control.
Turns the music on/off
Allows you to change the music category directly
Argument: The category (1, 2 or 3) of music we wish to select
Enable the legacy GUI
Disable the legacy GUI
Toggle the legacy GUI
Changes the volume just for the MusicManager
Fades the current song out smoothly
Fades in the current song smoothly
Fades the music out over a specified amount of time by setting the fade duration
Argument: The amount of time we want the fade to take
Fades the music in over a specified amount of time
Argument: How long we want the fade to take
Plays the song you want from the current category.
Argument: The index of the song you want to play. Indices start at 0 (not 1) so the first song is index 0, second is index 1 etc.
Plays the song you want from the current category, and loops it continuously.
Argument: The index of the song you want to play. Indices start at 0 (not 1) so the first song is index 0, second is index 1 etc.