Search Unity

Feedback Gamepad input registers even when standalone build isn't focused

Discussion in 'Input System' started by ElnuDev, Mar 1, 2020.

  1. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    I've been testing some networking stuff in my game, so I have multiple instance of my game running at once. In addition, I have my player Input Actions set up for use with gamepad and keyboard input. The weird thing going on is that my gamepad joystick input registers to all instances, but my keyboard only registers to the focused instance. Currently, I'm fixing the problem through script with
    Application.isFocused
    to ensure that only the focused instance gets input. Is this a bug with the new input system, or a feature...? Thanks in advance!
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Do you have "Run in Background" enabled in the player preferences? ATM it's entirely keyed to that. If it's enabled, the input system will keep running as part of the player loop and keep processing input of devices that are able to receive input without focus (keyboard and mouse no).
     
  3. ElnuDev

    ElnuDev

    Joined:
    Sep 24, 2017
    Posts:
    298
    Disabling that didn't seem to help. In the Player Settings, right?
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    So, been looking more into this and found that unfortunately there's some part of Unity (probably PlayerConnection) that is forcing Application.runInBackground *on* in development builds. In release builds, this works as expected and designed.

    After 1.0, I think we'll have to take another look at this and maybe introduce an explicit switch for forcing input off regardless of Application.runInBackground. Though at the same time it also strikes me as rather poor that there's some internals in Unity that just override the player setting like that.