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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Adding IPointerClickHandler blocks OnDrop from being called

Discussion in 'Scripting' started by ddbrown30, Jun 24, 2020.

  1. ddbrown30

    ddbrown30

    Joined:
    May 19, 2020
    Posts:
    9
    I have an object that I drag and drop around my canvas. All this was working fine until I added IPointerClickHandler to that script and now OnDrop is no longer being called (OnBeginDrag and OnDrag are still called correctly). I'm going to assume it has something to do with the click handler taking priority of the mouse handling, but I'm not sure how to override that. Anyone know what I need to do?
     
  2. ddbrown30

    ddbrown30

    Joined:
    May 19, 2020
    Posts:
    9
    I figured it out. In OnBeginDrag, I added the following code:

    Code (CSharp):
    1. eventData.eligibleForClick = false;
    This disables the click handling and gives priority back to OnDrop.