Continue Button with New Input System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Continue Button with New Input System

Post by cptscrimshaw »

Hi Tony,

I have Unity's "new" input system working for the Dialogue System, but I ran into an oddity that I'm hoping you can help with. Normally when I click the continue button, it finishes typing out the dialogue and then I have to hit continue again to go to the next node (this is what I want), but when I use a gamepad and hit the button (which I've titled Action in this case) it types out the rest of the line and immediately goes to the next node (not what I want).

Any ideas? Not much to show, but here's the code and a screenshot of my PlayerActions setup.

Code: Select all

using UnityEngine;
using UnityEngine.InputSystem;
using PixelCrushers;

public class RegisterMyControls : MonoBehaviour // Add me to Dialogue Manager.
{
    protected static bool isRegistered = false;
    private bool didIRegister = false;
    public PlayerActions controls;

    void Awake()
    {
        controls = new PlayerActions();
    }

    void OnEnable()
    {
        if (!isRegistered)
        {
            isRegistered = true;
            didIRegister = true;
            controls.Enable();
            InputDeviceManager.RegisterInputAction("Action", controls.PlayerControls.Action);
            InputDeviceManager.RegisterInputAction("Movement", controls.PlayerControls.Movement);
        }
    }

    void OnDisable()
    {
        if (didIRegister)
        {
            isRegistered = false;
            didIRegister = false;
            controls.Disable();
            InputDeviceManager.UnregisterInputAction("Action");
            InputDeviceManager.UnregisterInputAction("Movement");
        }
    }
}
PlayerActions: https://ibb.co/B2WZLjn
User avatar
Tony Li
Posts: 22037
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue Button with New Input System

Post by Tony Li »

Hi,

Since the continue button is a plain old Unity UI Button, you don't need to use InputDeviceManager.RegisterInputAction to register anything specifically for it. As long as your EventSystem is working properly, pressing the EventSystem's Submit action should click the button as normal.

If you've added a UI Button Key Trigger component, that may be double clicking the Button.
Post Reply