Music Player Breakdown

Back


Summary


The music player is a script that allow you to manage some basic background music within your games. The script lets you change the track via code with a few transitions to choose from. This script has a static instance by default and is not affected by the main Audio Manager static instance toggle.

Setup


The inspector for this script should be setup with the first track you wish to play, the rest of the tracks should be stored in your own scripting to be inserted into the player when needed. You set the track you wish to play in the inspector first & then configure the rest of the inspector for that track. The rest of the music player usage is via code.

Inspector Breakdown


SettingDescription
Track To PlayThe track that will play when will script is first called
Music Audio MixerThe audio mixer to play the clip from
Play On AwakeShould the click play on the Awake() method
Intro TransitionThe transition the player uses when the track first plays
Transition LengthThe length of the transition for changing tracks
Track VolumeEdits the volume of the clip between 0-1
Track PitchEdits the pitch of the track
Should Loop TrackShould the track loop once it reaches the end of the audio clip The looping of the track you select is optional, should you want to use it you'll need to set it up for each track you want to use. When calling to play a track in code you can set the start and end
Start Track AtThe time in seconds where the clip should start from
Loop Track AtThe point in seconds where the track will loop from