Rewired integration spacebar problem

Announcements, support questions, and discussion for the Dialogue System.
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Rewired integration spacebar problem

Post by leonfor »

Hi,

I'm back again with another hopefully quick and easy question. I've successfully integrated Rewired into the Dialogue System, so the "Button Name' in the UI Button Key Trigger is bound to a Rewired action and this works perfectly for the left mouse button and the Enter key (which are mapped to that action in Rewired).

I thought the spacebar (which is also mapped to that action in Rewired) would work the same but instead it keeps sending OnClick events to the Continue button even when Rewired maps are completely disabled (left mouse button and Enter key stop working accordingly). I figured this is because Unity sends an OnClick event on the last focused button with the spacebar by default. (this is really weird by the way, as I've also unmapped the "Submit" input in the input manager, but somehow it still works with the spacebar)

I have Always Auto Focus UNticked.

By messing around and trying various setups, I've noticed the spacebar starts acting correctly like the left mouse button/enter key after UNticking "Interactable" and ticking it back in the Button component of the Continue button in play mode. Is this behaviour intended? Maybe it's because the Continue button is focused by the event system by default at start and gets defocused with the UNtick/tick thing (and not getting focused back with Auto Focus UNticked).

I hope I've explained everything clearly, thank you in advance.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Rewired integration spacebar problem

Post by Tony Li »

Hi,

In general, if a key is assigned to the EventSystem's "Submit" input, don't also use that key in a UIButtonKeyTrigger component.

With Unity's built-in input, the EventSystem's "Submit" field is set to an input definition named "Submit" that's mapped to Space, Enter, left mouse button, and joystick button 0.

In Rewired, the EventSystem's "Submit" field is typically set to an action named "UISubmit". This action is usually mapped to Space, Enter, left mouse button, and joystick button 0.

When you press the "Submit" input, the EventSystem will click whatever button currently has focus (i.e., is "selected" in Unity UI terminology). However, if the same input is also mapped to a UIButtonKeyTrigger component, the UIButtonKeyTrigger will also click the button that it's on.

If you want to use Space or Enter on the continue button, and have it also work as normal behavior with Unity UI, then don't use a UIButtonKeyTrigger. Instead, tick the Dialogue Manager's Input Device Manager component > Always Auto Focus.
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Re: Rewired integration spacebar problem

Post by leonfor »

Hi,

sorry but I'm still not able to solve the issue despite the useful information you provided. The "Submit" input, both in the Dialogue Manager and in the Rewired Standalone Input Module, is bound to an action with is categorized under a category in Rewired which gets deactivated when a conversation starts.

The player can still continue through a conversation thanks to the UI Button Key Trigger which is bound to another Rewired action which is categorized under another category (which is instead active during a conversation). This action is mapped to left mouse mouse button, enter and spacebar.

WIth this setup, the issue is that if I disable all maps for the category of the action in the UI Button Key Trigger, the left mouse button and the enter key stop working as intended, but the spacebar keeps triggering the "Submit" input.

It's like there's an undeletable link between the spacebar and the "Submit" input :(
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Rewired integration spacebar problem

Post by Tony Li »

That's really strange. Are there any UI Button Key Triggers on the continue button? Or any anywhere in the scene that might be configured with an action that's mapped to Space? Then again, maybe it's a bug in the RewiredStandaloneInputModule component. Have you tried backing up your project and updating to the latest version of Rewired?

This is a long shot, but try setting the Dialogue Manager's Input Settings > Cancel Subtitle Input > Key and Cancel Conversation Key to None, and clear the Button fields.

If none of that helps, please feel free to send a reproduction project to tony (at) pixelcrushers.com.
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Re: Rewired integration spacebar problem

Post by leonfor »

Hi,

I can confirm there are no other UI Button Key Triggers or anything else bound to the spacebar in the scene. I've also tried setting the Cancel Subtitle Input and Cancel Conversation keys to None as well as clearing the Button fields, to no avail.

But I did make some progress through further testing: it appears that the issue only happens with the first dialogue entries for a dialogue panel, no matter which one (be it PC or NPC), until it gets superceded by the other dialogue panel, and then it works.

Example: a conversation starts with 3 dialogue entries from the player (PC panel); disabling the Rewired map correctly deactivates the enter key and the left mouse button, but spacebar keeps working until the first NPC dialogue entry comes in. At that point the spacebar stops working and behaves correctly (e.g. it doesn't work if I disable the rewired map) even during subsequent PC dialogue entries!

I've desperately tried to understand what could change between the start state of the dialogue panels and their state post-first-disable but I didn't notice anything useful unfortunately. What do you think could be the issue?

Thank you again
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Rewired integration spacebar problem

Post by Tony Li »

Hi,

I just tested a similar setup here, and I can't reproduce the issue. Would it be possible for you to send me a reproduction project?
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Re: Rewired integration spacebar problem

Post by leonfor »

Hi,

I've sent a little repro project to the email you specified. It has a link to this thread in the subject, and the email itself contains a brief description of the setup and the steps to reproduce the issue.

Thank you.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Rewired integration spacebar problem

Post by Tony Li »

Hi,

Thanks for putting together the reproduction project. I'm downloading it now. I'll let you know what I find.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Rewired integration spacebar problem

Post by Tony Li »

The RewiredStandaloneInputModule does not appear to consider whether a map is enabled or not. If you want to disable the space bar, disable the RewiredStandaloneInputModule.

If you're comfortable with code and want to trace through it yourself, an easy way is to add a Debug.Log() line to the beginning of the StandardUIContinueButtonFastForward script's OnFastForward() method. When you press Space, it will log a message with a stack trace to the Console window. From there, you can see that RewiredStandaloneInputModule.Update calls SendUpdateEventToSelectedObject(),
leonfor
Posts: 17
Joined: Tue Nov 30, 2021 6:31 am

Re: Rewired integration spacebar problem

Post by leonfor »

Hi,

thanks a lot for the heads up. I guess that still doesn't explain why the RewiredStandaloneInputModule suddenly starts behaving correctly at the first change of speaker in the conversation but we'll live with it or disable it entirely if there's ever a time in the game where the dialogue input (including the spacebar) needs to be deactivated in the very first conversation at scene load. (and before the very first change of speaker as well -- it's so random :D)
Post Reply