public float Speak(Dialogue.Entry entry) { AudioClip clip = entry.GetAudioClip(); float durationPerLetter = (clip != null && !entry.audioOnly) ? clip.length / entry.text.Length : 0.1f; if (entry.audioOnly && conversationCanvas.activeInHierarchy) { conversationCanvas.SetActive(false); } else if (!entry.audioOnly) { // if (!conversationCanvas.activeInHierarchy) { // conversationCanvas.SetActive (true); // } // animatedText.ShowText (entry.text, durationPerLetter); } if (clip != null) { voice.clip = clip; voice.Play(); return(clip.length); } return(entry.text.Length * 0.1f); }
/** * Script helper methods */ private IEnumerator PlayConversation() { while (true) { if (currentEntry >= dialogue.entries.Length) { yield break; } CancelInvoke("CloseConversation"); Dialogue.Entry entry = dialogue.entries [currentEntry]; float entryDuration = orb.Speak(entry); currentEntry++; if (!entry.autoContinue) { Invoke("CloseConversation", entryDuration + 2f); yield break; } else { yield return(new WaitForSeconds(entryDuration + 2f)); } } }