Author Topic: Bug with drag&drop  (Read 2290 times)

neopix

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Bug with drag&drop
« on: April 04, 2014, 08:31:18 AM »
Hello,

We have encountered a bug in the drag mechanic. When you start dragging an element, but release it for an instant and start dragging it again before it returns to its original position, the positioning of that element is way off and dragging doesn't work properly. Is there a solution for this problem?

Thanks,

Neopix

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug with drag&drop
« Reply #1 on: April 04, 2014, 01:25:22 PM »
Change UIDragDropItem.OnDragDropStart to this:
  1.         protected virtual void OnDragDropStart ()
  2.         {
  3.                 // Automatically disable the scroll view
  4.                 if (mDragScrollView != null) mDragScrollView.enabled = false;
  5.  
  6.                 // Disable the collider so that it doesn't intercept events
  7.                 if (mCollider != null) mCollider.enabled = false;
  8.  
  9.                 mTouchID = UICamera.currentTouchID;
  10.                 mParent = mTrans.parent;
  11.                 mRoot = NGUITools.FindInParents<UIRoot>(mParent);
  12.                 mGrid = NGUITools.FindInParents<UIGrid>(mParent);
  13.                 mTable = NGUITools.FindInParents<UITable>(mParent);
  14.  
  15.                 // Re-parent the item
  16.                 if (UIDragDropRoot.root != null)
  17.                         mTrans.parent = UIDragDropRoot.root;
  18.  
  19.                 Vector3 pos = mTrans.localPosition;
  20.                 pos.z = 0f;
  21.                 mTrans.localPosition = pos;
  22.  
  23.                 TweenPosition tp = GetComponent<TweenPosition>();
  24.                 if (tp != null) tp.enabled = false;
  25.  
  26.                 SpringPosition sp = GetComponent<SpringPosition>();
  27.                 if (sp != null) sp.enabled = false;
  28.  
  29.                 // Notify the widgets that the parent has changed
  30.                 NGUITools.MarkParentAsChanged(gameObject);
  31.  
  32.                 if (mTable != null) mTable.repositionNow = true;
  33.                 if (mGrid != null) mGrid.repositionNow = true;
  34.         }

neopix

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Bug with drag&drop
« Reply #2 on: April 05, 2014, 06:05:43 AM »
Thank you, that solved the problem.