[HOWTO] How To: Continue Without UI Button
Posted: Thu Dec 05, 2019 11:36 am
If you've set up your conversations to wait for a continue button click, normally the player will continue by clicking a UI button.
However, there are several ways to continue without the UI button:
1. Use the Continue() sequencer command in a sequence, such as the Sequence below to continue after 2 seconds:
2. Use the UI button, but size it to cover the whole screen, and set its Image color alpha to zero so it's invisible. This allows the player to click/tap anywhere onscreen to continue. You can usually move it to be a direct child of the Dialogue Panel and/or add a Layout Element and tick Ignore Layout. This will make it easier to configure the Rect Transform to cover the whole screen.
3. Add a UIButtonKeyTrigger to the UI button. This lets you map additional inputs to click the button. Don't use Space or Return for UIButtonKeyTrigger hotkeys; Space and Return are already used by the Unity UI EventSystem to click the current selection. If you add them to UIButtonKeyTrigger, they can end up incorrectly clicking the button twice.
4. Or remove the continue button(s) from your dialogue UI, and add this script to your Subtitle Text GameObjects:
ContinueFastForward.cs
However, there are several ways to continue without the UI button:
1. Use the Continue() sequencer command in a sequence, such as the Sequence below to continue after 2 seconds:
Code: Select all
Continue()@2
3. Add a UIButtonKeyTrigger to the UI button. This lets you map additional inputs to click the button. Don't use Space or Return for UIButtonKeyTrigger hotkeys; Space and Return are already used by the Unity UI EventSystem to click the current selection. If you add them to UIButtonKeyTrigger, they can end up incorrectly clicking the button twice.
4. Or remove the continue button(s) from your dialogue UI, and add this script to your Subtitle Text GameObjects:
ContinueFastForward.cs
Code: Select all
using PixelCrushers.DialogueSystem;
using UnityEngine;
public class ContinueFastForward : MonoBehaviour
{
public KeyCode[] continueKeys = new KeyCode[] { KeyCode.Space, KeyCode.Return };
void Update()
{
foreach (var key in continueKeys)
{
if (InputDeviceManager.IsKeyDown(key))
{
FastForward();
return;
}
}
}
void FastForward()
{
var typewriterEffect = GetComponent<AbstractTypewriterEffect>();
if ((typewriterEffect != null) && typewriterEffect.isPlaying)
{
typewriterEffect.Stop();
}
else
{
GetComponentInParent<AbstractDialogueUI>().OnContinue();
}
}
}