How to auto play the conversation skip the contunure button?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

How to auto play the conversation skip the contunure button?

Post by shortlin »

As title,

I want to set a button to let player could click it to see the story auto play.

I had no idea about this.is there a function in Dialogue system ?

Or get the typewriter,find the end time to use DialogueManager.conversationView.OnConversationContinueAll();?

But I did not find the finished function..
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to auto play the conversation skip the contunure button?

Post by Tony Li »

Hi,

If you want to advance each subtitle after the typewriter effect has finished -- but only if the player has clicked the auto-play button -- add a small script to the dialogue UI like this:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HandleAutoPlay : MonoBehaviour
{
    public bool autoplay;
    
    public void OnTypewriterFinished()
    {
        if (autoplay) GetComponent<StandardDialogueUI>().OnContinueConversation();
    }
}
Then inspect the subtitle text's typewriter effect. Configure the OnEnd() UnityEvent to call HandleAutoPlay.OnTypewriterFinished.

To turn on autoplay, set the script's autoplay variable true.
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: How to auto play the conversation skip the contunure button?

Post by shortlin »

Thank you,Tony.
I just want test what I thought if it is right.I write this code in Start After some seconds:

Code: Select all

        UnityAction endAction=()=>
        {
            [the Standard UI GameObject].GetComponent<StandardDialogueUI>().OnContinueConversation();
        };
        [The Typewriter GameObject].GetComponent<TextMeshProTypewriterEffect>().onEnd.AddListener(endAction);
But It seems could not run,the Unity always Crash.Could you point out what's wrong with this code?
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to auto play the conversation skip the contunure button?

Post by Tony Li »

I don't see anything immediately wrong. Try tracing through with the debugger or adding Debug.Log lines. If you can't find the issue, please feel free to send a reproduction project to tony (at) pixelcrushers.com.
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: How to auto play the conversation skip the contunure button?

Post by shortlin »

I had wroten Debug.Log.
It would run
when the dialogue system is opened and typewriter finished.

So I tried to let the fisrt time skip,but It would be crash when I used GetComponent<StandardDialogueUI>().OnContinueConversation();.

I run it in another computer,sometime it would not be crash,but it would be this error:

Couldn't extract exception string from exception of type StackOverflowException (another exception of class 'StackOverflowException' was thrown while processing the stack trace)
shortlin
Posts: 73
Joined: Wed Jun 03, 2020 1:52 am

Re: How to auto play the conversation skip the contunure button?

Post by shortlin »

Finnally I found my solution,just let OnContinueConversation() execute after 0.5 second.It will be ok.

Now,I Have another question is I want to use "ctrl" key to let the connversation speed up.when I enter the "ctrl",I use this code:

[TextMeshProTypewriter gameObject].GetComponent<TextMeshProTypewriterEffect>().charactersPerSecond =seedUp;
DialogueManager.displaySettings.subtitleSettings.subtitleCharsPerSecond = seedup;

And when exit the keyboard "ctrl" I used:

[TextMeshProTypewriter gameObject].GetComponent<TextMeshProTypewriterEffect>().charactersPerSecond =origenSpeed;
DialogueManager.displaySettings.subtitleSettings.subtitleCharsPerSecond = origenSpeed;

if I exit the ctrl and the typewriter has not finished,the words typing will stop.And I had no idea to solve this,Is there a better way to let all conversation speed up with enter "ctrl",release "ctrl" will recover the speed?

P.S I also set DialogueManager.displaySettings.subtitleSettings.subtitleCharsPerSecond,just becaule I want the{{end}} in sequence is right second,but it seems not really work.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to auto play the conversation skip the contunure button?

Post by Tony Li »

Hi,

You can adapt the scripts in this post to speed up or slow down the typewriter while it's typing.

This post has a speed-up example that includes the scripts.
Post Reply