Delay Continue Button?
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Delay Continue Button?
Hello,
My custom dialogue UI has a Continue Button and a Button for fast forwarding. Both are currently working fine. However, I would like to add a small wait period before the player can click continue or fast forward. This way they will not accidentally skip any dialogue.
Is there anyway to add a delay before the player can click continue?
My custom dialogue UI has a Continue Button and a Button for fast forwarding. Both are currently working fine. However, I would like to add a small wait period before the player can click continue or fast forward. This way they will not accidentally skip any dialogue.
Is there anyway to add a delay before the player can click continue?
Re: Delay Continue Button?
Hi,
Here are two ways to do that:
1. Make a subclass of StandardUISubtitlePanel. Use it for your subtitle panel. Override ShowContinueButton() to make the button non-interactable for a duration:
Or, if you don't want to make a subclass, you could just add a similar type of script to the continue button itself:
Designers more often want to prevent the player from accidentally choosing a response menu item when spamming the continue button. The response menu's Standard UI Response Menu component has a Block Input Duration. If you set it to 0.5, for example, it will not allow the player to click response buttons for the first 0.5 seconds.
Here are two ways to do that:
1. Make a subclass of StandardUISubtitlePanel. Use it for your subtitle panel. Override ShowContinueButton() to make the button non-interactable for a duration:
Code: Select all
public class MySubtitlePanel : StandardUISubtitlePanel
{
public override void ShowContinueButton()
{
base.ShowContinueButton();
continueButton.interactable = false;
Invoke(nameof(AllowContinueButton), 0.5f); // Make interactable after 0.5 seconds
}
void AllowContinueButton()
{
continueButton.interactable = true;
}
}
Code: Select all
public class AllowButtonAfterDelay : MonoBehaviour
{
private void OnEnable()
{
GetCompponent<Button>().interactable = false;
Invoke(nameof(AllowButton), 0.5f); // Make interactable after 0.5 seconds
}
void AllowButton()
{
GetComponent<Button>().interactable = true;
}
}
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: Delay Continue Button?
Hi, Tony
Thank you for not just always responding in a timely manner, but also providing multiple resolutions.
I went the route of adding this script to my Fast forward Button:
This seems to work for the first message in the conversation, but stops working when the following child message is displayed. My guess is it would need to be disabled and reenabled again after continuing.
What is the best way to apply this delay to every dialogue in the conversation?
Thank you for not just always responding in a timely manner, but also providing multiple resolutions.
I went the route of adding this script to my Fast forward Button:
Code: Select all
public class AllowButtonAfterDelay : MonoBehaviour
{
private void OnEnable()
{
GetComponent<Button>().interactable = false;
Invoke(nameof(AllowButton), 0.5f); // Make interactable after 0.5 seconds
}
void AllowButton()
{
GetComponent<Button>().interactable = true;
}
}
What is the best way to apply this delay to every dialogue in the conversation?
Re: Delay Continue Button?
Good catch. The continue button stays active when one line is immediate followed by another in the same subtitle panel, so it won't receive the OnEnable() message.
Instead, assuming your subtitle panel is part of the Dialogue Manager's hierarchy (e.g., instantiated into the Dialogue Manager's Canvas), you can change this method name:
to:
You'll also need to add this to the top of your script:
If it's not in the hierarchy, you can change the method name to something else, like:
and configure the Subtitle Text > typewriter effect's OnBegin() UnityEvent to call the method.
The other solution is to use a subclass of StandardUISubtitlePanel that overrides ShowContinueButton().
Instead, assuming your subtitle panel is part of the Dialogue Manager's hierarchy (e.g., instantiated into the Dialogue Manager's Canvas), you can change this method name:
Code: Select all
private void OnEnable()
Code: Select all
private void OnConversationLine(Subtitle subtitle)
Code: Select all
using PixelCrushers.DialogueSystem;
Code: Select all
public void DisableContinueButtonBriefly() // Note: now a public method
The other solution is to use a subclass of StandardUISubtitlePanel that overrides ShowContinueButton().
- PayasoPrince
- Posts: 104
- Joined: Thu Jan 27, 2022 6:47 pm
Re: Delay Continue Button?
Strangely enough, changing the method to:
Worked for the child dialogue messages, but wasn't being applied to the first message for some reason.
I ended up needing to use both:
This seems to give me the result I want but I'm not sure if using both methods will have anegative impact.
Code: Select all
private void OnConversationLine(Subtitle subtitle)
I ended up needing to use both:
Code: Select all
private void OnEnable()
{
GetComponent<Button>().interactable = false;
Invoke(nameof(AllowButton), 1f); // Make interactable after 1 seconds
}
private void OnConversationLine(Subtitle subtitle)
{
GetComponent<Button>().interactable = false;
Invoke(nameof(AllowButton), 1f); // Make interactable after 1 seconds
}
Re: Delay Continue Button?
No, that's totally fine. It probably wasn't being applied to the first line because the continue button GameObject wasn't active yet since the dialogue UI was still appearing.