private void OnCharacterRevealed(char c) { if (m_Config == null) { return; } /* * if (char.IsPunctuation(c) && m_Config.PunctuationClip && !punctuationSource.isPlaying) * { * voiceSource.Stop(); * punctuationSource.clip = m_Config.PunctuationClip; * punctuationSource.Play(); * } */ if (char.IsLetter(c) && m_Config.VoiceClip) { if (Time.unscaledTime - m_LastDialogueSound > m_TimeUntilNextDialogueSound) { m_TimeUntilNextDialogueSound = UnityEngine.Random.Range(0.02f, 0.08f); m_LastDialogueSound = Time.unscaledTime; audioSourceGroup.PlayFromNextSource(m_Config.VoiceClip); // Use Multiple Audio Sources to allow playing multiple sounds at once } // mouthQuad.localScale = new Vector3(1, 0, 1); // mouthQuad.DOScaleY(1, .2f).OnComplete(() => mouthQuad.DOScaleY(0, .2f)); } }
private void PlayDialogueSound(AudioClip voice_sound) { if (Time.unscaledTime - lastDialogueSound > timeUntilNextDialogueSound) { timeUntilNextDialogueSound = UnityEngine.Random.Range(0.02f, 0.08f); lastDialogueSound = Time.unscaledTime; audioSourceGroup.PlayFromNextSource(voice_sound); //Use Multiple Audio Sources to allow playing multiple sounds at once } }