Input System - Buttons not working in build but fine in editor

This issue has been driving me insane for the past days. In short, submit wont work in a build or when I choose to “build and run”.

‎‎ ‎

The project is set to Input System Package (new) only, and I am using version 2019.4.9f1.

‎‎ ‎

I have tried setting InputSystemUIInputModule’s pointer behaviour to all available options, and I’ve tried setting the Project Settings > Input System Package > Update Mode to all available options also.

‎‎ ‎

The other interesting aspect of this issue is that the same thing happens on a gamepad (pressing A to submit has the same effect - it prints out Submit but the button does nothing)!

‎‎ ‎

I’d appreciate some advice very much.
I’ll attach some screenshots of my settings, just in case at the end. Thank you.


Test Scene

I created a test scene in my project that consists of the following:

‎‎ ‎

  • A text that prints out current action
  • A button that when pressed, changes colour and displays a text on it
  • A gameobject that has an EventSystem, InputSystemUIInputModule, PlayerInput and a custom script on it that reads current action

‎‎ ‎

When running this in editor, it prints out the right actions, and when I press the button, it changes colour and displays text:

173978-5s3o6ir6lv.gif

‎‎ ‎

When running this in “Build and Run”, it prints out the right actions, the button gets highlighted when hovered, but it does not react to being pressed:

173979-mgijb0j77t.gif


Screenshots of my setup

  • Input System Package Settings:

‎‎ ‎

  • EventSystem, InputSystemUIInputModule and PlayerInput:

‎‎ ‎

  • in the input action map, Submit is set to action type “Button”:

https://i.imgur.com/ZRQqf0d.png & https://i.imgur.com/SjHhSWl.png

‎‎ ‎

  • Button:

‎‎ ‎

After seeing seeing some threads on this issue (links below), I finally managed to fix it! I put the PlayerInput on a separate GameObject from the EventSystem and the rest, then set the binding of the mouse left and right click actions in the action map to interaction: press only. Now it all works in both editor and in build. Hope this helps someone in the future.

https://forum.unity.com/threads/button-ui-not-working-with-the-new-input-system.797976/#post-6491277

https://forum.unity.com/threads/buttons-dont-react-with-input-system-ui-input-module-in-scene.748757/

https://forum.unity.com/threads/unity-new-input-system-multiplayereventsystem-and-inputsystemuiinputmodule-is-commented-out.885214/