Author Topic: OnDrag event not called on Android  (Read 7332 times)

gekido

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
OnDrag event not called on Android
« on: February 04, 2013, 02:46:18 PM »
Hello,

I've been experimenting with a drag n drop system for mobile.  It seems that the OnDrag event is not being sent every frame on Android.  Has anyone had any luck with this?

My OnDrag code is like so:

void OnDrag (Vector2 delta)
{
   if (enabled && UICamera.currentTouchID < 0)
   {
      Debug.Log ("Dragging! " + this.name);
      mTrans.localPosition += (Vector3)delta;
   }
}

Testing on the PC, the drag works fine, the object gets dragged around underneath no problem.  On mobile, the debug log is not being called and the object does not get dragged around.

Another option is to move this into the Update function (while (dragging){ do drag stuff } ), but I need to retrieve the 'delta' value (or calculate it myself), which kind of defeats the purpose of having the 'OnDrag()' functionality.

Any ideas?
Mike W

redhawk

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 34
    • View Profile
Re: OnDrag event not called on Android
« Reply #1 on: February 04, 2013, 02:49:30 PM »
I have the paid version of NGUI.  You should test build all of the examples.  I think there is one with an inventory that does what you are thinking.  It works just fine on my Android.  I tested ALL the examples on my Android tablet and they all function as they are supposed to. 

Hope that helps.

gekido

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: OnDrag event not called on Android
« Reply #2 on: February 04, 2013, 02:59:25 PM »
yeah i have the paid version as well, my code is pretty close to the drag n drop example.  your answer did point me in the right direction - i had the currentTouchID flag set wrong, reset it to the same as the example ( > -2) and it fixed the drag n drop.

thanx!