Fixed time delay between dialogue entries
Fixed time delay between dialogue entries
I made a quick search and didn't find a relevant thread.
I was wondering if there is a way to introduce an artificial delay between two dialogue entries. That is, making DS wait after the Continue() of the previous entry, before starting to execute the next one. Something like a given amount of time (0.016 sec) or a frame would be enough, I think.
It's not for story-telling purposes, but for making sure the rest of my engine has time to execute things in the background.
If this requires a change in DS, of course I don't expect you to modify this for every user. Telling me what should I change in the scripts would be more than enough.
Thanks!
I was wondering if there is a way to introduce an artificial delay between two dialogue entries. That is, making DS wait after the Continue() of the previous entry, before starting to execute the next one. Something like a given amount of time (0.016 sec) or a frame would be enough, I think.
It's not for story-telling purposes, but for making sure the rest of my engine has time to execute things in the background.
If this requires a change in DS, of course I don't expect you to modify this for every user. Telling me what should I change in the scripts would be more than enough.
Thanks!
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Fixed time delay between dialogue entries
Hi,
No need to change any Dialogue System scripts. If you're using StandardUIContinueButtonFastForward on your continue button, you can replace it with a subclass like this:
No need to change any Dialogue System scripts. If you're using StandardUIContinueButtonFastForward on your continue button, you can replace it with a subclass like this:
Code: Select all
using System.Collections;
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CustomStandardUIContinueButtonFastForward : StandardUIContinueButtonFastForward
{
public override void OnFastForward()
{
if ((typewriterEffect != null) && typewriterEffect.isPlaying)
{
base.OnFastForward();
}
else
{
StartCoroutine(ContinueAfterDelay());
}
}
IEnumerator ContinueAfterDelay()
{
continueButton.gameObject.SetActive(false);
yield return null; // <-- Delay 1 frame. Change if you want to delay longer.
base.OnFastForward();
}
}
Re: Fixed time delay between dialogue entries
Hi Tony, thanks for the fast reply.
This could work with player clicks and the "press Ctrl to skip" feature I have, yes, but what about entries with a Continue() command in the Sequence field? Will those call OnFastForward() as well, so the delay could be applied?
The thing is, your plugin is so awesome that I'm using DS for a lot more than just dialogue. I have a lot of nodes that execute sequence commands with a Continue() at the end, so they run pretty fast and sequentially. Therefore, it would be a bit safer if DS would add that delay in between, regardless if the continuing has been done by the player or not.
Also, in case the answer to the previous is yes, how could I wait for a fixed amount of time instead of a frame?
P.S.: I'm also getting this...
This could work with player clicks and the "press Ctrl to skip" feature I have, yes, but what about entries with a Continue() command in the Sequence field? Will those call OnFastForward() as well, so the delay could be applied?
The thing is, your plugin is so awesome that I'm using DS for a lot more than just dialogue. I have a lot of nodes that execute sequence commands with a Continue() at the end, so they run pretty fast and sequentially. Therefore, it would be a bit safer if DS would add that delay in between, regardless if the continuing has been done by the player or not.
Also, in case the answer to the previous is yes, how could I wait for a fixed amount of time instead of a frame?
P.S.: I'm also getting this...
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Fixed time delay between dialogue entries
To delay for a fixed time such as 0.25 seconds, change:
to:
Instead of the continue button subclass, try adding this script to the Dialogue Manager:
I'm in the middle of a project launch at the moment so I didn't have time to test it. It might have some issues, but that's the general idea.
Code: Select all
yield return null;
Code: Select all
yield return new WaitForSeconds(0.25f);
Code: Select all
using System.Collections;
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CustomFinishSubtitleScript : MonoBehaviour
{
void OnConversationStart(Transform actor)
{
DialogueManager.conversationView.FinishedSubtitleHandler -=
DialogueManager.conversationController.OnFinishedSubtitle;
DialogueManager.conversationView.FinishedSubtitleHandler += DelayThenFinishSubtitle
}
void DelayThenFinishSubtitle(object sender, EventArgs e)
{
StartCoroutine(FinishSubtitleAfterDelay(sender, e);
}
IEnumerator FinishSubtitleAfterDelay(object sender, EventArgs e)
{
yield return new WaitForSeconds(0.25f);
DialogueManager.conversationController.OnFinishedSubtitle(sender, e);
}
}
Re: Fixed time delay between dialogue entries
Thank you so much, Tony. I appreciate your time!
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Fixed time delay between dialogue entries
Glad to help! If it doesn't work, let me know. I typed it directly into the reply, so it might have typos.
Re: Fixed time delay between dialogue entries
Yup, I just needed to add a line and some semicolons. All good.
I also added a public float to change the waiting time on demand. I'll leave it here in case someone is interested.
Thanks!
I also added a public float to change the waiting time on demand. I'll leave it here in case someone is interested.
Code: Select all
using System;
using System.Collections;
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class CustomFinishSubtitleScript : MonoBehaviour
{
public float timeDelay = 0.016f;
void OnConversationStart(Transform actor)
{
DialogueManager.conversationView.FinishedSubtitleHandler -=
DialogueManager.conversationController.OnFinishedSubtitle;
DialogueManager.conversationView.FinishedSubtitleHandler += DelayThenFinishSubtitle;
}
void DelayThenFinishSubtitle(object sender, EventArgs e)
{
StartCoroutine(FinishSubtitleAfterDelay(sender, e));
}
IEnumerator FinishSubtitleAfterDelay(object sender, System.EventArgs e)
{
yield return new WaitForSeconds(timeDelay);
DialogueManager.conversationController.OnFinishedSubtitle(sender, e);
}
}
Unity 2019.4.9f1
Dialogue System 2.2.15
Dialogue System 2.2.15
Re: Fixed time delay between dialogue entries
Thanks for fixing and sharing the code!