Search Unity

IPointerDownHandler and IPointerUpHandler

Discussion in 'Input System' started by Lord_Eniac, Feb 16, 2021.

  1. Lord_Eniac

    Lord_Eniac

    Joined:
    Jan 28, 2020
    Posts:
    50
    These interfaces were working splendidly in 2018.4, but after updating my project to 2019.4 neither function as they once did. Has something changed? I tried both the old and the new input systems. Neither work. The methods for OnPointerUp and OnPointerDown will fire in Unity 2018, but not 2019.

    Edit: I forgot to mention that the methods fire when running in the editor, however when I install to my Android device, they do not.
     
    Last edited: Feb 16, 2021
  2. Lord_Eniac

    Lord_Eniac

    Joined:
    Jan 28, 2020
    Posts:
    50
    I've confirmed that the two interfaces are working in brand new projects, so some other asset that I'm using must be the culprit. That being the case... back to 2018.4.
     
  3. Lord_Eniac

    Lord_Eniac

    Joined:
    Jan 28, 2020
    Posts:
    50
    After discovering that downgrading to Unity 2018 resulted in all of my Image scripts suddenly becoming null, I went back to Unity 2019.

    I figured out my problem. I had a test to see if either Input.GetMouseButton(0) (for editor) or Input.touchCount >= 1 (for mobile) was true inside the handler for the IPointerUpHandler interface. Turns out that in Windows, GetMouseButton(0) return false, but for Android, apparently the touchCount is not updated prior to the handler being called. I was more concerned with handling edge cases where the handler might be called if a user had two or more positions touched and released a finger (no idea if this would cause the handler to fire or not). Anyway, for those who might face a similar head-scratcher, Input.touchCount may equal one inside OnPointerUp() when a single touch release occurs.