public void Play(string audioKey) { var audioClip = _audioStorage.GetAudioClip(audioKey); if (audioClip != null) { var audioSource = _audioSourcePool.GetNext(); audioSource.clip = audioClip; audioSource.Play(); this.WaitUntil(() => !audioSource.isPlaying, () => _audioSourcePool.Return(audioSource)); } }
public void Play(string audioKey) { var audioClip = _audioStorage.GetAudioClip(audioKey); if (audioClip != null) { var audioSource = _audioSourcePool.GetNext(); audioSource.clip = audioClip; audioSource.Play(); _activeAudioSources.Add(audioSource); } }
public void Play(string audioKey) { var audioClip = _audioStorage.GetAudioClip(audioKey); if (audioClip != null) { if (_checkCapacity) { var activeAudio = _activeAudioSources.FindAll(s => s.clip == audioClip); if (activeAudio.Count >= _audioStorage.GetCapacity(audioKey)) { return; } } var audioSource = _audioSourcePool.GetNext(); audioSource.clip = audioClip; audioSource.Play(); _activeAudioSources.Add(audioSource); } }