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

New Input System: on-screen button release event trigger on mobile device (Android)

Discussion in 'Input System' started by ezp303, Dec 19, 2020.

  1. ezp303

    ezp303

    Joined:
    May 13, 2020
    Posts:
    1
    Hello,

    I have simple On-Screen Button (new Input System component), like this:

    upload_2020-12-19_23-11-7.png

    Control path is set to left arrow on keyboard, and left arrow is binded to MoveLeft action:

    upload_2020-12-19_23-20-3.png

    I have callback methods to handle action events in my Player Controller:

    upload_2020-12-19_23-23-42.png

    and MoveLeft action handler function looks like this:


    upload_2020-12-19_23-26-51.png

    It basically works fine on PC in Editor - when I press down left mouse button, I have log "btn press" in console. When I release the left mouse button, I have a "btn release" log at the right moment, no matter how long I held that button.

    But on Android device build, and this is the main issue - when i push this screen button, first action event (with context.started) is triggered correctly, but afer that immediately second event (with context.canceled) is triggered, while i'm still hold this screen button. When i release this button really - nothing happens and no event is trigerred. It would be nice to have right event triggered on time, when button is really released on mobile touch screen. Any ideas what happens here ?

    I've tried some different settings:

    - Different settings in Input System UI Input Module on EventSystem object
    - Different action types (value / button / pass)
    - Changing On-Screen Button component Control Path (keyboard arrow / joystick left)
    - With and without standard "Button" canvas component

    ..but no luck ;[

    Android Logcat says all this, immediately after button push and hold:

    2020.12.19 23:57:43.257 11282 11282 Debug ViewRootImpl@6d1943c[UnityPlayerActivity] ViewPostIme pointer 0
    2020.12.19 23:57:43.288 11282 11313 Info Unity btn press
    2020.12.19 23:57:43.288 11282 11313 Info Unity PlayerController1:OnInputMoveLeft(CallbackContext)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.Events.UnityAction`1:Invoke(T0)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.Events.UnityEvent`1:Invoke(T0)
    2020.12.19 23:57:43.288 11282 11313 Info Unity System.Action`1:Invoke(T)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.Utilities.DelegateHelpers:InvokeCallbacksSafe(InlinedArray`1&, TValue, String, Object)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:CallActionListeners(Int32, InputActionMap, InputActionPhase, InlinedArray`1&, String)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ChangePhaseOfActionInternal(Int32, TriggerState*, InputActionPhase, TriggerState&)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ChangePhaseOfAction(InputActionPhase, TriggerState&, InputActionPhase)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ChangePhaseOfInteraction(InputActionPhase, TriggerState&, InputActionPhase)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:processInteractions(TriggerState&, Int32, Int32)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:processControlStateChange(Int32, Int32, Int32, Double, InputEventPtr)
    2020.12.19 23:57:43.288 11282 11313 Info Unity UnityEngine.InputSystem.InputManager:FireStateChangeNotif
    2020.12.19 23:57:43.293 11282 11313 Info Unity btn release
    2020.12.19 23:57:43.293 11282 11313 Info Unity PlayerController1:OnInputMoveLeft(CallbackContext)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.Events.UnityAction`1:Invoke(T0)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.Events.UnityEvent`1:Invoke(T0)
    2020.12.19 23:57:43.293 11282 11313 Info Unity System.Action`1:Invoke(T)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.Utilities.DelegateHelpers:InvokeCallbacksSafe(InlinedArray`1&, TValue, String, Object)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:CallActionListeners(Int32, InputActionMap, InputActionPhase, InlinedArray`1&, String)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ChangePhaseOfActionInternal(Int32, TriggerState*, InputActionPhase, TriggerState&)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ChangePhaseOfAction(InputActionPhase, TriggerState&, InputActionPhase)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ChangePhaseOfInteraction(InputActionPhase, TriggerState&, InputActionPhase)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ResetInteractionStateAndCancelIfNecessary(Int32, Int32, Int32)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:ResetActionState(Int32, InputActionPhase)
    2020.12.19 23:57:43.293 11282 11313 Info Unity UnityEngine.InputSystem.InputActionState:DisableAllActions(InputActio


    And this single line when button was released:

    2020.12.19 23:57:43.813 11282 11282 Debug ViewRootImpl@6d1943c[UnityPlayerActivity] ViewPostIme pointer 1

    I hope my explain is clear :)

    Thanks & Greetins

    Piotr
     

    Attached Files:

    ben4d85 likes this.
  2. Holonet

    Holonet

    Joined:
    Aug 14, 2017
    Posts:
    84
    Struct InputAction.CallbackContext | Input System | 1.0.1 (unity3d.com)
    According to that...

    Note that an action may also change its phase in response to a timeout. For example, a TapInteraction will cancel itself if the button control is not released within a certain time. When this happens, the control property will be the control that last fed input into the action.

    ... So that's a bummer, but it seems this might have some use: How do I…? | Input System | 1.0.1 (unity3d.com)
    About halfway down, there's some code for getting all the current active touches on a touchscreen. Might be able to use that to get around this issue, though I haven't built to Android myself, so just a thought.
     
  3. ben4d85

    ben4d85

    Joined:
    Dec 26, 2018
    Posts:
    47

    Did you ever find a solution for this problem?

    I have a similar problem, see https://forum.unity.com/threads/mobile-button-release-not-triggered.1294332/
     
    Last edited: Jun 11, 2022