private void Update() { if (AudioHelper.FadingOut) { // Don't process any of queue while fading out return; } if (nextClip) { nextClipDelay -= Time.deltaTime; if (nextClipDelay <= 0.0f) { // Fading out sets volume to 0, ensure we're playing at the right // volume every time audioSource.volume = defaultVolume; audioSource.PlayOneShot(nextClip); nextClip = null; } } else if (clipQueue.Count > 0 && !audioSource.isPlaying) { QueuedAudioClip queuedClip = clipQueue.Dequeue(); if (queuedClip.clip && (queuedClip.allowReplay || !playedClips.Contains(queuedClip.clip.name))) { nextClip = queuedClip.clip; nextClipDelay = queuedClip.delay; playedClips.Add(nextClip.name); } } }
private void Update() { if (AudioHelper.FadingOut) { // Don't process any of queue while fading out return; } if (nextClip) { nextClipDelay -= Time.deltaTime; if (nextClipDelay <= 0.0f) { // Fading out sets volume to 0, ensure we're playing at the right // volume every time if (audioSource != null) { audioSource.volume = defaultVolume; } audioService.PlayClip(nextClip, out audioSource); nextClip = null; } } else if (clipQueue != null && clipQueue.Count > 0 && (audioSource == null || !audioSource.isPlaying)) { QueuedAudioClip queuedClip = clipQueue.Dequeue(); if (queuedClip.clip && (queuedClip.allowReplay || !playedClips.Contains(queuedClip.clip.name))) { nextClip = queuedClip.clip; nextClipDelay = queuedClip.delay; if (queuedClip.blockProgress) { playStartTime = DateTime.UtcNow; clipLength = nextClip.length + queuedClip.delay; } else { playStartTime = DateTime.MinValue; clipLength = 0; } playedClips.Add(nextClip.name); } } }
public bool PlayClip(QueuedAudioClip clip, bool replaceQueue = false) { return(PlayClip(clip.clip, clip.delay, clip.allowReplay, replaceQueue)); }