IEnumerator PlaySoundDelay(AudioSource audio, float delay) { Sound sound = audio.GetComponent <Sound> (); // Check that the sound component exists if (sound == null) { Debug.LogError(audio.name + ": Sound script missing!"); } // Wait for the delay yield return(new WaitForSeconds(delay)); // Stop other sounds from playing, if necessary if (soundTypes[sound.type].stopOthers) { StopSoundsInDirectory(soundTypes [sound.type].directory); } // Play the audio file audio.Play(); // Show subtitles if (sound.showSubtitles && sound.subtitles.Length > 0) { subtitleManager.StartSubtitles(audio); } }