I just updated to version 1.1.1 mainly because I wanted this change from 1.1.0-preview.2:
The submit and the cancel actions of the UI input module now trigger on release instead of press. This makes the behavior consistent with clicks triggering UI response on release rather than press.
However, this is not true, the submit and cancel actions events are still sent on press instead of release in my UI. Thinking that this change maybe only affects the deafult actions asset, I explicitly added Press interactions to my Submit and Cancel actions and set them to Release Only, and double-checked that the actions are correctly linked in the UI input module. Still, these actions are triggered on press.
Is there anything special I need to do after updating?
I created a minimal project as a sanity check, it’s attached (created with Unity 2021.1 and Input System 1.1.1).
The SampleScene consists of simply a button that is the first selection, and I put a Debug.Log in the OnClick event handler. When you run the scene and simply press and hold Enter without releasing, you will see that the click event is triggered, which means that the submit action has been triggered on press and not release.
To conclude my monologue, I manually switched to 1.1.0-preview.2 via the package manager and there it works as advertised. It also works in 1.1.0-pre.5, but in 1.1.0-pre.6 it’s reacting to press again instead of release, so whatever happened in the update to preview 6 undid the change of preview 2.
It seems this issue persists for Unity InputSystem 1.4.2. This sucks because I even found the source of the problem. I can’t change it because it’s a package and I don’t really want to put this into my Assets Folder.
This right here is the problem:
protected bool SendSubmitEventToSelectedObject()
{
if (eventSystem.currentSelectedGameObject == null)
return false;
var data = GetBaseEventData();
if (input.GetButtonDown(m_SubmitButton))
ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.submitHandler);
if (input.GetButtonDown(m_CancelButton))
ExecuteEvents.Execute(eventSystem.currentSelectedGameObject, data, ExecuteEvents.cancelHandler);
return data.used;
}
It’s a really simple fix too. You just have to change it from GetButtonDown to GetButtonUp in the GetButtonDown Method that is found in a script called BaseInput. Although if it were up to me I would just make another method that detects when the button is Up and use that method instead. Other scripts could be using this method.
public virtual bool GetButtonDown(string buttonName)
{
return Input.GetButtonDown(buttonName);
}
From what I understand there is no issue officially. They introduced the change in one preview and reverted it in another because they felt it was a bad idea, so I guess the case is closed, and I wouldn’t waste any hope that it’s ever going to be changed again.
I guess if you want the different behaviour, you’ll have to make that change in the source code. At least the packages are open source so this can be done.