Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug ReadValue() not updating when losing focus

Discussion in 'Input System' started by LHAppri, Jun 16, 2022.

  1. LHAppri

    LHAppri

    Joined:
    Aug 18, 2017
    Posts:
    20
    I have a custom HID device talking to Unity through the new Input System Package (1.3.0). Currently the inputs are simply outputting to a display to show what is happening, using InputControl.IsPressed() or AxisControl.ReadValue(). Whenever the game window loses focus (in Editor or Standalone) these inputs are no longer updated and continue to report the same value although the Unity update itself is still working. Reselecting the Game window starts them updating again.
    The values in the InputDebugger also stop updating as soon as the GameView loses focus, even if I just click on the InputDebugger itself.

    ShowLosingFocus.jpg

    I have looked thoroughly at the Input System Documentation (1.3 & earlier versions) and have tried multiple settings but nothing seems to achieve what I need, which is for the inputs to always update regardless of focus.

    According to
    https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/manual/Settings.html#background-behavior
    setting Editor Mode : Play Mode Input Behavior to All Device Input Always Goes to Game View (or Pointers & Keyboards Respect Game Focus) should do what I want in the Editor, but neither works.
    I also have Background Behavior set to Ignore Focus
    InputSystemPackageSettings.jpg


    Application.runInBackground is set to true.

    Application.runInBackground.jpg

    The Custom HID InputDevice has canRunInBackground set to true
    InputDevice.canRunInBackground.jpg

    Any body have any ideas what else I can try?
     
  2. LHAppri

    LHAppri

    Joined:
    Aug 18, 2017
    Posts:
    20
    Anybody?
    Can a Unity person at least confirm if Background Behavior is set correctly or if I've misunderstood the documentation?
     
  3. dmytro_at_unity

    dmytro_at_unity

    Unity Technologies

    Joined:
    Feb 12, 2021
    Posts:
    212
    Yes it looks correct. On which platform/Unity version you observe this? I remember some instances where we were placing HID polling thread into sleep when Unity loses focus, but need to confirm with the actual code, maybe this is what you see as well.