Audio Player Breakdown

Back


Summary


The audio player script lets you play clips from a Audio Manager File library from the inspector. This is designed for use with UI elements and UnityEvents. This is designed to just be a basic stopgap as you'll more commonly want to write your own implementation for playing specific audio.

Setup


The setup for the audio player is really simple. You will need an audio manager file to use this script which you’ll need for the audio manager script as well. You’ll need to assign the audio manager file you have to the script to use it. Once assigned you’ll gain access to the rest of the script.

From there you can assign a mixer to play from for the clips and a collection of clips that you can play. You can add or remove clips with the +/- buttons and have as many clips as you want. The volume & pitch options let you define a range to select randomly from. You can set both a delay & time to play the clip from per clip in the optional settings. Note that all these clips will play at the same time. To play the audio from the player just call the play method from the class in your code or via a unity event etc.

Inspector Breakdown


SettingDescription
Audio Manager FileThe audio manager file that is used for this player.
Audio MixerThe mixer group to play the audio from.

Settings that are the same per clip you add:

SettingDescription
Clip NameThe name of the clip you want to play, this has to be a clip that is currently in the audio manager file entered at the top of the player for it to work.
Volume The volume the clip should play as, this is limited between 0-1, you can set a range to choose random from with the lower on the left and the higher on the right. If you don’t want to use this just set both to the same value. Use a mixer group or increase in the audio clip file to change it further if needed.
PitchThe pitch for the clip to play at. You can set a range to choose random from with the lower on the left and the higher on the right. If you don’t want to use this just set both to the same value.
From TimeThe start time clip should play from.
Clip DelayThe delay there should be before the clip should play.