/** * Show subtitle */ public IEnumerator IShowSubtitle(string subtitle, Pawn speaker, AudioClip audio = null, float duration = -1f, Action completed = null) { if(duration < 0) { if(audio != null) { duration = audio.length + SPEAKING_PAUSE; } else { int wordAmount = subtitle.Split(' ').Length; duration = wordAmount / WORDS_PER_SECOND + SPEAKING_PAUSE; } } foreach(OnShowSubtitleDelegate callback in this.showSubtitleCallbacks) { StartCoroutine(callback(speaker.title, subtitle, duration)); } speaker.PlaySound(audio); yield return new WaitForSeconds(duration); if(completed != null) { completed(); } }