Author Topic: 3.0.2 DragDropItem can drop erroneously  (Read 1883 times)

KyleStaves

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
3.0.2 DragDropItem can drop erroneously
« on: October 23, 2013, 11:02:09 AM »
I'm sure there is also an issue on how I have my object set up, but it manifests itself in a way I would consider a bug with NGUI as well.

So basically I have a DropDropItem that has a collider of course. Part of that DragDropItem is a button (nested under the DragDropItem root). Clicking the button can cause Drop() to be called in situations where OnDrag is never called. I fixed it by changing:

  1. mIsDragging = false;
  2.                         Collider col = collider;
  3.                         if (col != null) col.enabled = !isPressed;
  4.                         if (!isPressed) Drop();
  5.  
  6. to
  7.  
  8.  
  9. if (mIsDragging)
  10.                         {
  11.                                 mIsDragging = false;
  12.                                 if (!isPressed) Drop();
  13.                         }
  14.  
  15.                         Collider col = collider;
  16.                         if (col != null) col.enabled = !isPressed;
  17.  
  18.  

in OnPress of DragDropItem.cs


EDIT:
I forgot to mention that this is an issue because 'dropping' an object that has never been dragged causes the depth to creep lower in increments of 100.
« Last Edit: October 23, 2013, 11:24:25 AM by KyleStaves »

JMab

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: 3.0.2 DragDropItem can drop erroneously
« Reply #1 on: October 23, 2013, 05:16:33 PM »
Yes, I think that is a bug too - I put in my own fix yesterday.

To be fair, it's in the example code, rather than the core NGUI library, so some tweaks to the code are probably expected.