Пример #1
0
        static IEnumerator DelayedCallback(AudioClip clip, float time, object callback)
        {
            string cName = "";

            if (clip != null)
            {
                cName = clip.name;
            }
            yield return(new WaitForSeconds(time));

            CLSoundPool.returnObj(cName);
            if (clip != null)
            {
                Utl.doCallback(callback, clip);
            }
        }
Пример #2
0
 public static void stopMainMusic()
 {
     if (self == null)
     {
         Debug.LogError("Need Attack [SoundEx] to a gameObject");
         return;
     }
     if (self.mainAudio.isPlaying)
     {
         self.mainAudio.Pause();
     }
     if (self.mainAudio.clip != null)
     {
         CLSoundPool.returnObj(self.mainAudio.clip.name);
         self.mainAudio.clip = null;
     }
 }
Пример #3
0
 public static void doPlaySound(AudioClip clip, float volume, int maxTimes = 1)
 {
     if (clip == null)
     {
         return;
     }
     try {
         if (playSoundCount [clip.name] == null || (int)(playSoundCount [clip.name]) < maxTimes)
         {
             playSoundCount [clip.name] = (playSoundCount [clip.name] == null ? 1 : (int)(playSoundCount [clip.name]) + 1);
             Callback cb = finishPlaySound;
             PlaySoundWithCallback(clip, volume, cb);
         }
         else
         {
             CLSoundPool.returnObj(clip.name);
         }
     } catch (System.Exception e) {
         Debug.LogError(e);
     }
 }
Пример #4
0
 public static void doPlayMainMusic(AudioClip clip)
 {
     try {
         if (self.mainAudio.clip != clip)
         {
             if (self.mainAudio.clip != null)
             {
                 CLSoundPool.returnObj(self.mainAudio.clip.name);
             }
             self.mainAudio.Stop();
             self.mainAudio.clip = clip;
             self.mainAudio.Play();
         }
         else
         {
             if (!self.mainAudio.isPlaying)
             {
                 self.mainAudio.Play();
             }
         }
     } catch (System.Exception e) {
         Debug.LogError(e);
     }
 }