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

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:
    35
    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:
    35
    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,117
    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?