// ====================================================================================== // PRIVATE MEMBERS // ====================================================================================== private IEnumerator PlayAudioClip(SoundLib.sSoundEvent _soundEvent) { GameObject soundObj = new GameObject(); soundObj.transform.parent = m_soundSpawnner; AudioSource source = soundObj.AddComponent <AudioSource>(); source.clip = _soundEvent.m_clip; source.volume = _soundEvent.m_volume; source.Play(); float timer = _soundEvent.m_clip.length; while (timer > 0) { yield return(null); if (this.IsActive()) { timer -= GameMgr.DeltaTime; if (!source.isPlaying) { source.UnPause(); } } else { source.Pause(); } } Destroy(soundObj); }
// ====================================================================================== // PRIVATE MEMBERS // ====================================================================================== private IEnumerator PlayAudioClip(SoundLib.sSoundEvent _soundEvent) { GameObject soundObj = new GameObject(); soundObj.transform.parent = m_soundSpawnner; AudioSource source = soundObj.AddComponent <AudioSource>(); source.clip = _soundEvent.m_clip; source.volume = _soundEvent.m_volume; source.Play(); float timer = _soundEvent.m_clip.length; while (timer > 0) { yield return(null); timer -= Time.deltaTime; } Destroy(soundObj); }