Welcome to Unity Learning,Unity training ,UnityEnterprise TrainingEducation Area, there are manyu3d Resources,u3d Training Video,u3d Tutorials,U3d Frequently Asked questions,u3d Project Source code, the "Dog Planing Learning Network" Unity's Ultimate Academy, dedicated to building the industry unity3d Training , learning the first brand.
The most common components of sound management in the game are Audiosource and AudioClip, and my approach is to build a Audiomanager class (singleton) to manage each audio and talk about my experience:
Start () function: Sets the overall audio parameters;
Inspector panel: Drag-and-drop file assignment
View related APIs
Main logic:
Public
void Playsoundeffect (Soundeffects soundeffect)
{
AudioClip clip = null;
float pitch = 1;
Switch (soundeffect) {
Case Soundeffects.obstaclecollisionsoundeffect:
Clip = obstaclecollision;
Break
Case Soundeffects.coinsoundeffect:
Clip = coincollection;
Pitch = 1.5f;
Break
Case Soundeffects.powerupsoundeffect:
Clip = powerupcollection;
Break
Case Soundeffects.gameoversoundeffect:
Clip = Gameover;
Break
Case Soundeffects.guitapsoundeffect:
Clip = Guitap;
Break
}
Soundeffectsaudio.pitch = pitch;//Tone
Soundeffectsaudio.clip = clip;//
Soundeffectsaudio.play ();
}
For more information, please visit the "Dog Planing Learning Network" Unity Ultimate Academy Http://edu.gopedu.com
Statement: This document comes from the "Dog Planing Learning Network" Community-unity Extreme College, is a self-published Unity3d study articles, if anything violates your relevant interests, please communicate with the official, we will deal with the real-time.
[3D Parkour] Audiomanager