protected virtual IEnumerator SayInternal(string text, bool clearPrevious, bool waitForInput, bool fadeWhenDone, AudioClip voiceOverClip, Action onComplete) { Writer writer = GetWriter(); // Stop any existing Say Command and write this one instead // This will probably take a frame or two to complete while (writer.isWriting || writer.isWaitingForInput) { writer.Stop(); yield return(null); } this.fadeWhenDone = fadeWhenDone; // Voice over clip takes precedence over a character sound effect if provided AudioClip soundEffectClip = null; if (voiceOverClip != null) { WriterAudio writerAudio = GetWriterAudio(); writerAudio.PlayVoiceover(voiceOverClip); } else if (speakingCharacter != null) { //soundEffectClip = speakingCharacter.soundEffect; } writer.Write(text, clearPrevious, waitForInput, soundEffectClip, onComplete); }
protected WriterAudio GetWriterAudio() { if (writerAudio != null) { return(writerAudio); } writerAudio = GetComponent <WriterAudio>(); if (writerAudio == null) { writerAudio = gameObject.AddComponent <WriterAudio>(); } return(writerAudio); }