Game Development Reference
In-Depth Information
Figure 11-17. “Loop 16 - 145 bpm - complete” in the Project panel and the Inspector
Uncheck 3D sound so the volume will be uniform regardless of the player character's position
or movement. Select the Audio game object in the Hierarchy, select “Apply” if prompted by an
Unapplied import settings dialog, and drag the “Loop 16 - 145 bpm - complete” audio clip into the
Audio Source component's Audio Clip property field. Play On Awake should be checked by default.
If not, go ahead and check it. Since this is background music that you want to have play uniformly
the entire time the game is being played, give it the highest priority of 0. Save the scene and play.
The audio clip plays from start to finish, then stops. Try checking the Loop property of the Audio
Source and play again. Now the audio clip repeats, but not very smoothly between loops, which is
where the partial audio clips come into play.
To have continuous background music, you want the intro to play once at the beginning followed by
the loop section that will keep on looping, and for this behavior you'll need a script.
In the Project panel, select the Assets ➤ Scripts folder, then create a new script named
BackgroundMusic. Open it in MonoDevelop and edit the code to the following:
#pragma strict
function Start () {
PlayBackgroundMusic();
}
 
Search WWH ::




Custom Search