Skip button
-
- Posts: 57
- Joined: Sun Feb 12, 2017 2:11 pm
Skip button
It's been a long time since my last post.
It's good to be back.
Sir Tony Li,
I know it would be possible so I would just like to ask on how
would I make a skip button?
I would prefer it to be like when a conversation starts, aside from the continue button
there would be a skip button that allows me to skip what the NPC is saying. Upon skipping, I want to
be stopped on choosing choices only (if there is need). Then, back the NPC dialogue and
another skip and continue button (just a loop).
As along as there is a choice that I could skip what the NPC is saying.
Thanks in advance sir Tony!
It's good to be back.
Sir Tony Li,
I know it would be possible so I would just like to ask on how
would I make a skip button?
I would prefer it to be like when a conversation starts, aside from the continue button
there would be a skip button that allows me to skip what the NPC is saying. Upon skipping, I want to
be stopped on choosing choices only (if there is need). Then, back the NPC dialogue and
another skip and continue button (just a loop).
As along as there is a choice that I could skip what the NPC is saying.
Thanks in advance sir Tony!
Re: Skip button
Hi David!
Here's an example scene: SkipButtonExample_2017-12-21.unitypackage
It uses a script named SkipButton. Add this script to your Dialogue Manager. Then create a Skip button, and set the button's OnClick() event to SkipButton.SkipToResponseMenu.
The script is below, too:
SkipButton.cs
Here's an example scene: SkipButtonExample_2017-12-21.unitypackage
It uses a script named SkipButton. Add this script to your Dialogue Manager. Then create a Skip button, and set the button's OnClick() event to SkipButton.SkipToResponseMenu.
The script is below, too:
SkipButton.cs
Code: Select all
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
public class SkipButton : MonoBehaviour
{
public bool skip;
private AbstractDialogueUI dialogueUI;
private void Awake()
{
dialogueUI = GetComponentInChildren<AbstractDialogueUI>();
}
public void SkipToResponseMenu()
{
skip = true;
dialogueUI.OnContinue();
}
void OnConversationLine(Subtitle subtitle)
{
if (skip) StartCoroutine(ContinueAtEndOfFrame());
}
IEnumerator ContinueAtEndOfFrame()
{
yield return new WaitForEndOfFrame();
dialogueUI.OnContinue();
}
void OnConversationResponseMenu(Response[] responses)
{
skip = false;
}
}
Re: Skip button
Now that I think about it, you'll probably want to add this method to the script:
This turns off the skip when the conversation ends, so it doesn't skip when you start a new conversation.
Code: Select all
void OnConversationEnd(Transform actor)
{
skip = false;
}
-
- Posts: 57
- Joined: Sun Feb 12, 2017 2:11 pm
Re: Skip button
Alright! Thanks sir Tony! I'll try this sooner or later when I'm back home.
Still in a vacation! Hope your having a great holiday!
Thanks again!
Still in a vacation! Hope your having a great holiday!
Thanks again!
Re: Skip button
Sounds good. Enjoy your vacation!
Re: Skip button
Sorry for highjacking the thread, but I've stolen this little nice script for my new VN-style project, he he...
And yes, it's working beautifully!
I have one question though, to further "enhance" the feature.
How could a little delay be added, so instead of skipping blazingly fast, every frame, it sends DialogueUI.OnContinue() after a configurable amount of time?
What I'd like to see is the dialogue skipping very fast, but not so fast that the next thing I see after clicking the button is the next Response panel.
Could this be easily added to the script? Or it would be going too far?
And yes, it's working beautifully!
I have one question though, to further "enhance" the feature.
How could a little delay be added, so instead of skipping blazingly fast, every frame, it sends DialogueUI.OnContinue() after a configurable amount of time?
What I'd like to see is the dialogue skipping very fast, but not so fast that the next thing I see after clicking the button is the next Response panel.
Could this be easily added to the script? Or it would be going too far?
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Skip button
You could change the ContinueAfterOneFrame method to ContinueAfterShortDelay, something like:
However, a few other devs have implemented a fast-forward instead. To do this, they set the subtitle line's typewriter effect to a really fast value, like 200 characters per second, and set the Dialogue Manager's Subtitle Settings to skip ahead quickly. Something like:
This script plays the typewriter at 200 characters per second, automatically skipping ahead as soon as the typewriter finishes. When it gets to a response menu, it reverts to the original subtitle settings.
Code: Select all
IEnumerator ContinueAfterShortDelay()
{
yield return new WaitForSeconds(1); // Skip ahead after a 1-second delay.
dialogueUI.OnContinue();
}
Code: Select all
using UnityEngine;
using System.Collections;
using PixelCrushers.DialogueSystem;
public class SkipButton : MonoBehaviour
{
private float minSubtitleSeconds = 2;
private float subtitleCharsPerSec = 30;
private float typewriterCharsPerSec = 50;
private UnityUIDialogueUI dialogueUI;
private UnityUITypewriterEffect typewriter;
private void Awake()
{
dialogueUI = GetComponentInChildren<UnityUIDialogueUI>();
typewriter = dialogueUI.dialogue.npcSubtitle.line.GetComponent<UnityUITypewriterEffect>();
}
public void SkipToResponseMenu()
{
skip = true;
// Save original values:
minSubtitleSeconds = DialogueManager.DisplaySettings.subtitleSettings.minSubtitleSeconds;
subtitleCharsPerSec = DialogueManager.DisplaySettings.subtitleSettings.subtitleCharsPerSeconds;
typewriterCharsPerSec = typewriter.charactersPerSecond;
// Set values to fast forward:
typewriter.charactersPerSecond = 200;
DialogueManager.DisplaySettings.subtitleSettings.subtitleCharsPerSecond = 200;
DialogueManager.DisplaySettings.subtitleSettings.minSubtitleSeconds = 0;
DialogueManager.DisplaySettings.subtitleSettings.continueButton = ContinueButtonMode.Never;
// Skip this line:
dialogueUI.OnContinue();
}
void OnConversationResponseMenu(Response[] responses)
{
// Set original values:
typewriter.charactersPerSecond = typewriterCharsPerSec;
DialogueManager.DisplaySettings.subtitleSettings.subtitleCharsPerSecond = subtitleCharsPerSec;
DialogueManager.DisplaySettings.subtitleSettings.minSubtitleSeconds = minSubtitleSeconds;
DialogueManager.DisplaySettings.subtitleSettings.continueButton = ContinueButtonMode.Always;
}
}
Re: Skip button
Nice! I like the simplicity of the first solution, and it's working exactly as I envisioned so, thanks!
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
-
- Posts: 57
- Joined: Sun Feb 12, 2017 2:11 pm
Re: Skip button
Good day Sir Tony.
Now, for my new question.
I believe there is a way to have a previous button for the conversations.
So, I would like to ask how would I do it?
I just wanted to have a previous button so that user
can review the previous dialogue that the user
might have continued accidentally.
Thank you sir!
Now, for my new question.
I believe there is a way to have a previous button for the conversations.
So, I would like to ask how would I do it?
I just wanted to have a previous button so that user
can review the previous dialogue that the user
might have continued accidentally.
Thank you sir!