Esempio n. 1
0
    public IEnumerator PlayForTime(SourceWithTime soundWT)
    {
        soundWT.source.loop = true;
        soundWT.source.Play();
        yield return(new WaitForSeconds(soundWT.time));

        soundWT.source.Stop();
        soundWT.source.loop = false;
    }
Esempio n. 2
0
 public void PlayLoopedSoundForTime(AudioSource _source, AudioClip _sound, float time)
 {
     if (_source != null && _sound != null)
     {
         _source.Stop();
         _source.clip = _sound;
         SourceWithTime soundWT = new SourceWithTime(_source, time);
         StartCoroutine("PlayForTime", soundWT);
     }
 }