Page 1 of 1

Continue Button with New Input System

Posted: Wed May 12, 2021 4:44 pm
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

Re: Continue Button with New Input System

Posted: Wed May 12, 2021 5:26 pm
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.