Page 1 of 2
Unity New Input System support questions
Posted: Mon Mar 16, 2020 12:00 pm
by ProvencalG
Hi.
I was happy to notice that the new input system was supported since the last update.
Still I am struggling with it.
I can't manage to use the new input system with the dialogue system. I defined the scripting symbol USE_NEW_INPUT. I created and defined my actions, control schemes and bindings in an Input Actions Asset.
But I'm lost when in the input manual you say
"you must register them with the Input Device Manager before calling any of the InputDeviceManager input query functions". Giving this example:
Code: Select all
void Awake()
{
controls = new MyControls();
}
void OnEnable()
{
controls.Enable();
InputDeviceManager.RegisterInputAction("Back", controls.Gameplay.Back);
InputDeviceManager.RegisterInputAction("Horizontal", controls.Gameplay.Horizontal);
}
void OnDisable()
{
controls.Disable();
InputDeviceManager.UnregisterInputAction("Back");
InputDeviceManager.UnregisterInputAction("Horizontal");
}
I guess that "controls" should be defined above, "InputActionAsset controls;". I also guess that using "UnityEngine.InputSystem;" and "PixelCrushers.DialogueSystem" is mandatory.
What is "MyControls()" exactly?
Should I create a script that register inputs in a similar way? When should I enable and disable it? Multiple controls schemes are all registered at once that way? Is there a way to treat control schemes differently?
Thanks.
Re: Unity New Input System support questions
Posted: Mon Mar 16, 2020 2:30 pm
by Tony Li
Hi!
The new Input System is still in preview. I'm sure Unity will provide better documentation and tutorials as it gets closer to release, as well as best practices for using it. I'll continue updating the Dialogue System's integration as the Input System develops.
When you edit an input actions asset, the Input Manager window has a checkbox to
Generate C# Class. The Dialogue System's documentation example assumes that you've generated a C# class named MyControls.cs.
You should create a script that registers your own inputs in a similar way. If you're only concerned about Dialogue System-specific inputs, such as the "Cancel Conversation" input defined in the Dialogue Manager's Input Setting section, then you can enable it when a conversation starts and disable it when the conversation ends. You can use a
Dialogue System Events component on the Dialogue Manager to enable/disable the script, or you can add
OnConversationStart and OnConversationEnd methods to your script.
Re: Unity New Input System support questions
Posted: Tue Mar 17, 2020 3:27 pm
by ProvencalG
Thanks! I did not think about that C# Class.
I wonder, can I use the Player Input component and create events that trigger Dialogue System functions ?
For example StopConversation() from DialogueSystemController.
Anyway, now I'm trying to use those inputs I registered to answer specific response choice. In my conversations I have 3 choices maximum in each dialogue node. So I want 3 different inputs to trigger the max 3 different dialogue answers. I have no idea how.
Re: Unity New Input System support questions
Posted: Tue Mar 17, 2020 3:44 pm
by Tony Li
Hi,
ProvencalG wrote: ↑Tue Mar 17, 2020 3:27 pmI wonder, can I use the Player Input component and create events that trigger Dialogue System functions ?
For example StopConversation() from DialogueSystemController.
I haven't tested to be sure, but I think you can do that.
ProvencalG wrote: ↑Tue Mar 17, 2020 3:27 pmAnyway, now I'm trying to use those inputs I registered to answer specific response choice. In my conversations I have 3 choices maximum in each dialogue node. So I want 3 different inputs to trigger the max 3 different dialogue answers. I have no idea how.
If you want to map them to the number keys 1, 2, 3, then just turn on the Standard UI Menu Panel's Autonumbering.
If you want to map them to different inputs:
1. Register each input using InputDeviceManager.RegisterInputAction, such as:
Code: Select all
InputDeviceManager.RegisterInputAction("Response1", controls.dialogue.response1);
2. Add all 3 response buttons to the Standard UI Menu Panel's Buttons list.
3. Then add a UI Button Key Trigger to response button 1, and set the button name to "Response1". Do similarly for buttons 2 & 3.
Re: Unity New Input System support questions
Posted: Wed Mar 25, 2020 9:20 am
by ProvencalG
Hi,
So I tried that method and I don't know what I'm missing but no input I registered shows up in the Buttons list.
Do I need to register them using a specific name "Response1" etc? I tried that and it still does not show up.
Maybe I don't register my inputs properly.
Because I would expect them to show up in one of the InputDeviceManager lists in the inspector if it was registered.
Re: Unity New Input System support questions
Posted: Wed Mar 25, 2020 9:33 am
by Tony Li
Hi,
Assign Button 1, Button 2, and Button 3 to the StandardUIMenuPanel's Design-Time Buttons > Buttons > Element 0, Element 1, and Element 2.
Add a UIButtonKeyTrigger component to each of the buttons. If you want to map the "1 key" input to Button 1, set the UIButtonKeyTrigger's Button Name field to "1 key".
Re: Unity New Input System support questions
Posted: Thu Mar 26, 2020 8:45 pm
by ProvencalG
Hi,
So I tried and it does not trigger responses.
For exemple my button 1 UiButtonKeyTrigger is set up like this:
My inputs work. And I think they are registered (my only guess is a debug.log at the end or the RegisterInputAction commands).
Re: Unity New Input System support questions
Posted: Thu Mar 26, 2020 10:24 pm
by Tony Li
Hi,
Here's an example scene:
DS_NewInputSystemExample_2020-03-26.unitypackage
I copied DemoScene1 and made as few changes as possible -- just setting up new Input System hotkeys for the first two response buttons (mapped to '1' and '2'). I didn't set up input for player movement, so the player can't move around. The conversation starts immediately.
I've also fixed a small bug since the 2.2.5 release. When the new Input System support is enabled, UIButtonKeyTrigger doesn't like the Key dropdown to be "None". This patch fixes it:
DS_InputDeviceManager_Patch_2020-03-26.unitypackage
If your scene doesn't work after importing the patch and checking against the example scene, please check the Console for any errors or warnings.
Re: Unity New Input System support questions
Posted: Fri Mar 27, 2020 10:21 am
by ProvencalG
Yes it works!
In your demo and in my project.
Thanks a lot for your support!
I have a few other issues:
It does not trigger the pressed sprite of the button. I can create a script for that but still I'm letting you know.
And I have a probably unrelated issue, well, it's linked to the new input system I believe:
It does not happen in your demo so I guess this is probably my fault.
Re: Unity New Input System support questions
Posted: Fri Mar 27, 2020 10:31 am
by ProvencalG
That might help you