Search Unity

Bug [New InputSystem] Sensors stop working after app loses focus (like opening keyboard)

Discussion in 'Input System' started by ceast33, Jan 14, 2021.

  1. ceast33

    ceast33

    Joined:
    Apr 22, 2020
    Posts:
    9
    Whatever their value was at the moment I open the keyboard, they will return the same after even if my Android device is moved around.

    many values like:
    AttitudeSensor.current.attitude.ReadValue()
    Accelerometer.current.acceleration.ReadValue()
    LinearAccelerationSensor.current.acceleration.ReadValue()

    (And Gyroscope.current.angularVelocity.ReadValue() rarely works for me (even before opening keyboard), which I posted in previous thread)

    Im using Unity 2020.1.10f1, & we are migrating to the new InputSystem.
     
  2. ceast33

    ceast33

    Joined:
    Apr 22, 2020
    Posts:
    9
    Also happens when the app loses focus!
     
  3. mdroxas

    mdroxas

    Joined:
    Jul 30, 2018
    Posts:
    2
    Did you find a fix?
     
  4. ceast33

    ceast33

    Joined:
    Apr 22, 2020
    Posts:
    9
    I made a workaround! I disable the sensor in OnApplicationFocus(false) and re-enable it OnApplicationFocus(true).
     
  5. ceast33

    ceast33

    Joined:
    Apr 22, 2020
    Posts:
    9
    It doesnt work for the Gyroscope though (which what I was using before the Input System Migration)