Exemple #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!");
     }
 }
Exemple #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);
                 }
             }
         }
     }
 }