Search Unity

How to detect Right Click on UI objects?

Discussion in 'Input System' started by losingisfun, Jan 25, 2022.

  1. losingisfun

    losingisfun

    Joined:
    May 26, 2016
    Posts:
    36
    Our team recently swapped over to the new input system but for some reason we can no longer use the IPointerDownHandler (Or PointerUp).

    When we implement OnPointerDown(PointerEventData eventData) and attempt to check the eventData.pointerId it always equals 2. Whereas in past we could check for -1 or -2 for left/right click.

    What is the recommended alternative to using IPointerDownHandler?
     
  2. losingisfun

    losingisfun

    Joined:
    May 26, 2016
    Posts:
    36
    I found that using InputButton on the PointerEventData still works. But for some reason pointerId is always == 2
     
  3. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    Same for me, it's 2 for Left, Right or Middle mouse buttons.
    What's more frustrating, on a mobile device, instead of returning a finger id, it returns some very large numbers that are incremented each time you touch and stop touching the screen.
    What is going on?
     
  4. Razrabrrr

    Razrabrrr

    Joined:
    Oct 6, 2021
    Posts:
    20
    Any solutions?