Author Topic: OnDragOut event firing when press is released  (Read 3135 times)

fisheye

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
OnDragOut event firing when press is released
« on: September 19, 2014, 02:43:07 PM »
I'm trying to implement a radial menu, where the user presses down on a world object, and several UI Buttons are placed around it, then they drag a finger to a button and release.

I have a gameobject reference in my controller storing which button received the OnDragOver event, and I set the reference to null when OnDragOut is received. 

The problem is I receive OnDragOut when I release the original press.  It seems to me that OnDragOut should only fire when the drag actually leaves the bounds of the collider while still being dragged.  Perhaps we could get OnPress(false) or OrDragRelease or something when the click is released over something that was dragged over?

I would use UICamera.hoveredObject but I need this to work on touch devices.  Any thoughts on ways around this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnDragOut event firing when press is released
« Reply #1 on: September 19, 2014, 08:39:58 PM »
Straight from UICamera, line 1761:
  1.                                 // If there was a drag event in progress, make sure OnDragOut gets sent
  2.                                 if (currentTouch.dragStarted)
  3.                                 {
  4.                                         if (onDragOut != null) onDragOut(currentTouch.last, currentTouch.dragged);
  5.                                         Notify(currentTouch.last, "OnDragOut", currentTouch.dragged);
  6.  
  7.                                         if (onDragEnd != null) onDragEnd(currentTouch.dragged);
  8.                                         Notify(currentTouch.dragged, "OnDragEnd", null);
  9.                                 }
As you can see OnDragOut and OnDragEnd are both sent out if the UICamera.currentTouch.dragStarted is true. This is done for consistency, so that a start state is always followed by an end state. If you don't want this notification, set it to 'false'.