Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'Input System' started by theembracedone, Jan 10, 2021.

  1. theembracedone

    theembracedone

    Joined:
    Jul 31, 2019
    Posts:
    22
    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:



    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:



    Input System Package Settings


    EventSystem, InputSystemUIInputModule and PlayerInput:


    in the input action map, Submit is set to action type "Button"



    Button:
     
  2. theembracedone

    theembracedone

    Joined:
    Jul 31, 2019
    Posts:
    22
    After seeing seeing some threads on this issue (this, this and and this), 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.
     
  3. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    This doesn't work for the UI part, btw. - adding the UI Input Module will automatically add an Event System on the same gameobject.