Exemplo n.º 1
0
 public void Play(string soundName, bool randPitch, bool loop, spatialization space, Vector3 pos, float distMin = 0, float distMax = 0)
 {
     if (sounds.ContainsKey(soundName))
     {
         AudioData ad = sounds[soundName];
         if (ad != null)
         {
             AudioSource auSo = GetFreeAudioSource(ad.priority);
             auSo.clip = ad.GetClip();
             auSo.outputAudioMixerGroup = ad.group;
             auSo.spatialBlend = (float)space;
             auSo.gameObject.transform.position = pos;
             auSo.minDistance = distMin;
             auSo.maxDistance = distMax;
             if (randPitch)
             {
                 auSo.pitch = Random.Range(ad.pitchMin, ad.pitchMax);
             }
             else
             {
                 auSo.pitch = 1;
             }
             auSo.Play();
         }
     }
 }
Exemplo n.º 2
0
 public void Play(string soundName, bool randPitch, bool loop, spatialization space = spatialization.AUDIO_2D, float distMin = 0, float distMax = 0)
 {
     Play (soundName, randPitch, loop, space, Vector3.zero, distMin, distMax);
 }
Exemplo n.º 3
0
 public void Play(string soundName, bool loop, spatialization space = spatialization.AUDIO_2D, float distMin = 0, float distMax = 0)
 {
     Play (soundName, false, loop, space, distMin, distMax);
 }