For all Unity developers and developers-to-be, both beginners and professionals!
A simple tutorial on how to change the soundtrack / background music played in Car Tutorial project.
Posted by feillyne on Oct 21st, 2010
Basic Sound Effects.
In Car Tutorial project, it's quite simple.
1. Open CarEdu (/CarTutorial) project, find and expand directory in Project tab:
So you see CarTutorialSong.mp3 file
2. Find your .mp3 file, then drag it into the directory where CarTutorialSong is
3. Untick 3D Sound, tick Decompress On Load, click Apply
4. Select Car object (the main parent object, not its child parts), scroll down to Sound Controller (Script), then change Background Music by clicking the circle next to the name, and set it to your mp3 file.
backgroundMusic = gameObject.AddComponent(AudioSource); backgroundMusic.loop = true; backgroundMusic.playOnAwake = true; backgroundMusic.clip = BackgroundMusic; backgroundMusic.maxDistance = BackgroundMusicVolume; backgroundMusic.minDistance = BackgroundMusicVolume; backgroundMusic.volume = BackgroundMusicVolume;