TextMeshPro typewriter audio question

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
diviocity
Posts: 22
Joined: Sun Feb 25, 2018 12:50 am

TextMeshPro typewriter audio question

Post by diviocity »

Hi,

I've been using the TextMeshPro Typewriter Effect and noticed the alternate audio sources feature doesn't seem to be working. I added many different audio files but it only acknowledges/plays the one referenced in the Audio Clip field. I recall using this in the past (before TMP) and remember it working fine, randomly playing the clips. Just wondering if I'm forgetting something here.

Thanks!
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: TextMeshPro typewriter audio question

Post by Tony Li »

Hi,

That was an oversight on my part when consolidating code for version 2. You can download a fix here:

TMPTypewriter_2018-08-29.unitypackage
diviocity
Posts: 22
Joined: Sun Feb 25, 2018 12:50 am

Re: TextMeshPro typewriter audio question

Post by diviocity »

Thank you Tony for the quick work! It now works fantastic, thank you!

I suppose I'll leave a small feature request here as well. While we enjoy the rapidity of the "interrupt audio clip" feature, it results in some pretty harsh clipping when playing new clips. Would it be possible to layer the sounds as they play per character so that they don't harshly interrupt each other?

Thanks again, really appreciate all your help!
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: TextMeshPro typewriter audio question

Post by Tony Li »

Sure, I'll add that in the next release.
diviocity
Posts: 22
Joined: Sun Feb 25, 2018 12:50 am

Re: TextMeshPro typewriter audio question

Post by diviocity »

Awesome! Thank you!! I'll definitely be looking forward to it!
diviocity
Posts: 22
Joined: Sun Feb 25, 2018 12:50 am

Re: TextMeshPro typewriter audio question

Post by diviocity »

Hi Tony! We managed to solve this problem ourselves with an easy fix. I was wondering if you'd consider implementing it as a new feature. Again, our goal was the following:

1. Play a sound for each character displayed
2. Do not interrupt a playing sound as a new one begins

Our solution involved altering the interruptAudioClip script in AbstractTypewriterEffect, changing from audioSource.Play to audioSource.PlayOneShot.

Code: Select all

if (interruptAudioClip)
            {
                //if (audioSource.isPlaying) audioSource.Stop();
                if (randomClip != null) audioSource.clip = randomClip;
                audioSource.PlayOneShot(audioSource.clip);
            }
            else
            {
                if (!audioSource.isPlaying)
                {
                    if (randomClip != null) audioSource.clip = randomClip;
                    audioSource.PlayOneShot(audioSource.clip);
                }
Doing this allowed each sound to play completely for each character displayed.

I realize our solution isn't exactly an "interrupt", but using the base interrupt feature, as previously mentioned, produces a very harsh crackle between clips, which made it unusable for us. Please consider a PlayOneShot option ("play entire sound per character" or something) within the typewriter component. Right now we're re-implementing this change between versions.

Thank you so much!
User avatar
Tony Li
Posts: 21069
Joined: Thu Jul 18, 2013 1:27 pm

Re: TextMeshPro typewriter audio question

Post by Tony Li »

You got it. I'll make that change in version 2.1.5 and add it as a new checkbox that you can tick.
Post Reply