Skip to content

Conversation

@PrimCarol
Copy link

Improved sound playback for each letter, now the sound plays once a letter has been displayed. Before, the sound was played at the beginning of the interpretation of each letter, regardless of how long it took to be displayed, being out of sync with the audio and the display of the letter.


...
// To save the letters already displayed. 
List<int> charactersShowed = new List<int>();
...

public IEnumerator AnimateTextIn(List<DialogueCommand> commands, string processedMessage, AudioClip voice_sound, Action onFinish){
    ...
    // When the letter reaches its maximum size, it is saved as already displayed, and then the sound is played.
    if (charSize == 1 && !charactersShowed.Contains(j)){
        PlayDialogueSound(voice_sound);
        charactersShowed.Add(j);
    }
    ...
}

And a small sanity check in case you don't want or forget to put an audio.

private void PlayDialogueSound(AudioClip voice_sound){
    // Sanity Check
    if (audioSourceGroup == null || voice_sound == null) { return; }
    ...
}

Improved sound playback for each letter, now the sound plays once a letter has been displayed.
Before, the sound was played at the beginning of the interpretation of each letter, regardless of how long it took to be displayed, being out of sync with the audio and the display of the letter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant