Esempio n. 1
0
 public void PlayAudio(GameObject obj, string clipName, bool loop)
 {
     if (audioNames.Contains(clipName))
     {
         if (obj != null)
         {
             int index = audioNames.IndexOf(clipName);
             if (activeCount[index] < clipLimit[index])
             {
                 PooledAudio pAudio = obj.GetComponent <PooledAudio> ();
                 if (pAudio != null)
                 {
                     pAudio.Define(audioClips [index], audioVolumes [index], audioPans [index], audioPitches[index], audioPriorities [index], loop, audioPersistence[index]);
                     try {
                         pAudio.SetMixerGroup(mixerGroupArray[mixerGroupID[index]]);
                     } catch {
                         pAudio.SetMixerGroup(mixerGroupArray[0]);
                     }
                     pAudio.Play();
                     if (objectPool.eventMode > 0)
                     {
                         PoolMasterEvents.EventPlayAudio(clipName, obj);
                     }
                 }
             }
         }
     }
     else
     {
         Debug.LogWarning("PlayAudio: Clip '" + clipName + "' does not exist!");
     }
 }
Esempio n. 2
0
 public void PlayAudio(GameObject obj, int index, bool loop)
 {
     if (obj != null)
     {
         int i = Mathf.Clamp(index, 0, audioNames.Count);
         if (activeCount[index] < clipLimit[index])
         {
             PooledAudio pAudio = obj.GetComponent <PooledAudio> ();
             if (pAudio != null)
             {
                 pAudio.Define(audioClips [i], audioVolumes [i], audioPans [i], audioPitches[i], audioPriorities [i], loop, audioPersistence[index]);
                 try {
                     pAudio.SetMixerGroup(mixerGroupArray[mixerGroupID[index]]);
                 } catch {
                     pAudio.SetMixerGroup(mixerGroupArray[0]);
                 }
                 pAudio.Play();
                 if (objectPool.eventMode > 0)
                 {
                     PoolMasterEvents.EventPlayAudio(audioNames[i], obj);
                 }
             }
         }
     }
 }
Esempio n. 3
0
 public void StopAudio(string clipName)
 {
     if (audioNames.Contains(clipName))
     {
         foreach (GameObject g in objectPool.GetPool("ADVANCED AUDIO").pool)
         {
             PooledAudio pAudio = g.GetComponent <PooledAudio>();
             if (pAudio != null)
             {
                 if (pAudio.ClipIndex == audioNames.IndexOf(clipName))
                 {
                     g.GetComponent <AudioSource>().Stop();
                     objectPool.Despawn(g);
                 }
             }
         }
     }
 }