Interlocking key configuration with conversation start button

Announcements, support questions, and discussion for the Dialogue System.
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Interlocking key configuration with conversation start button

Post by gaku2_sigehiro »

Hello.
I created a key configuration using InputSystem's Rebinding, but it is not reflected in the conversation start button.
With reference to the documentation, I created a script that outputs the Input System in C# and passes button input to ProximitySelector.
Should I add a command to the script that passes key input to the Input System?
I don't know what to do, so could you please tell me?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interlocking key configuration with conversation start button

Post by Tony Li »

Hi,

Did you register that input action with the Dialogue System's InputDeviceManager as described on page 5 of the Input_Device_Manager_Manual.pdf included in the Dialogue System or in the tutorial video?
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Interlocking key configuration with conversation start button

Post by gaku2_sigehiro »

I created a script like this by referring to that pdf.
The buttons can be operated, but the buttons after key configuration are not reflected and are in the default key state.
Is there anything else I need to do?

Code: Select all

using UnityEngine;
using UnityEngine.InputSystem;
using PixelCrushers;
public class Controls : MonoBehaviour
{
    protected static bool isRegistered = false;
    private bool didIRegister = false;
    private KeyAction controls;
    void Awake()
    {
        controls = new KeyAction();
    }
    void OnEnable()
    {
        if (!isRegistered)
        {
            isRegistered = true;
            didIRegister = true;
            controls.Enable();
            InputDeviceManager.RegisterInputAction("Submit", controls.UI.Submit);
        }
    }
    void OnDisable()
    {
    if (didIRegister)
        {
            isRegistered = false;
            didIRegister = false;
            controls.Disable();
            InputDeviceManager.UnregisterInputAction("Submit");
        }
    }
}
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interlocking key configuration with conversation start button

Post by Tony Li »

Hi,

Where are you using "Submit"? For example, are you using a Selector component? If so, you would set the Use Button to "Submit" (without quotes). Can you provide screenshot(s) of your configuration?
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Interlocking key configuration with conversation start button

Post by gaku2_sigehiro »

Hello.
"Submit" is attached to the Player's "ProximitySelector" and used to start a conversation.
We will also send the settings for EventSystem.
240725a.jpg
240725a.jpg (186.09 KiB) Viewed 740 times
240725b.jpg
240725b.jpg (139.77 KiB) Viewed 740 times
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interlocking key configuration with conversation start button

Post by Tony Li »

Hi,

Have you added your Controls script to a GameObject such as the Dialogue Manager?

Are there any errors or warnings in the Console window?
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Interlocking key configuration with conversation start button

Post by gaku2_sigehiro »

Hello.
I am assembling it by watching videos and pdfs.
Of course, I attached a Controls script to Dialogue Manager.
There are no errors.
Operation with the default keys is possible.
It's just that it's not reflected when I keybind InputSystem.
240726a.jpg
240726a.jpg (218.53 KiB) Viewed 709 times
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interlocking key configuration with conversation start button

Post by Tony Li »

Hi,

Unlike dialogue UIs (response menu buttons, continue button), the Selector doesn't use the Unity UI EventSystem. When your script registers "Submit" with the InputDeviceManager, the InputDeviceManager will make a link between the string "Submit" and your Controls script's Submit input action. At runtime, the Selector then asks the InputDeviceManager is "Submit" is currently pressed, which makes the InputDeviceManager ask your Controls script if the Submit input action is pressed.

Maybe the problem is that it's named "Submit", which is also a name used by the Unity UI EventSystem. Can you try a different input action name such as "Use" or "Interact"?
gaku2_sigehiro
Posts: 36
Joined: Sun Jul 14, 2024 2:35 am

Re: Interlocking key configuration with conversation start button

Post by gaku2_sigehiro »

I changed the name to "Talk" as a trial.
I thought the south button was in the wrong place, so I checked by using the left stick as the default button.
But it will behave the same as before.
What should I do?

Code: Select all

using UnityEngine;
using UnityEngine.InputSystem;
using PixelCrushers;
public class Controls : MonoBehaviour
{
    protected static bool isRegistered = false;
    private bool didIRegister = false;
    private KeyAction controls;
    void Awake()
    {
        controls = new KeyAction();
    }
    void OnEnable()
    {
        if (!isRegistered)
        {
            isRegistered = true;
            didIRegister = true;
            controls.Enable();
            InputDeviceManager.RegisterInputAction("Talk", controls.UI.Talk);
        }
    }
    void OnDisable()
    {
    if (didIRegister)
        {
            isRegistered = false;
            didIRegister = false;
            controls.Disable();
            InputDeviceManager.UnregisterInputAction("Talk");
        }
    }
}
240726b.jpg
240726b.jpg (177.57 KiB) Viewed 689 times
240726c.jpg
240726c.jpg (137.4 KiB) Viewed 689 times
I created the key configuration method for InputSystem by referring to the following site.
I'm Japanese, so this is a Japanese site.
https://gamedev65535.com/entry/unity_in ... rebinding/
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Interlocking key configuration with conversation start button

Post by Tony Li »

Hi,

Here's an example:

DS_RebindInputSystemExample_2024-07-25.unitypackage

It's a copy of DemoScene1, but I replaced the DemoInputRegistration script with a copy that also listens for the [F1] key. When the [F1] key is pressed, it rebinds the "Fire1" input action to the "E" key. When you look at the NPC and press "E", it will start the conversation.
Post Reply