Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: ahaykal on May 23, 2015, 05:02:37 AM

Title: Drag & Drop Question
Post by: ahaykal on May 23, 2015, 05:02:37 AM
Hello Nguiers,

I would like to ask a question concerning drag and drop.
My issue is the following:

I have 2 containers/grids that I am moving items between them. Everything is working fine but I am wondering if it is possible to do this:

Right now, when I click and drag I move the sprite and on releasing the object it gets sorted in the grid.
Is it possible to sort it while dragging and not when the dragging ends?
I was wondering if anyone could help me with this matter !

Thank you for your help!
Title: Re: Drag & Drop Question
Post by: ahaykal on May 25, 2015, 02:15:04 AM
Bump?
Title: Re: Drag & Drop Question
Post by: ArenMook on May 26, 2015, 02:56:35 PM
Sure, you can do what you want. Just listen to OnDrag events (or OnDragOver if you want to be more efficient) and call the grid's sorting.
Title: Re: Drag & Drop Question
Post by: ahaykal on May 27, 2015, 03:15:53 AM
The problem with that is the dragged object isn't reparented, so calling the grid sort isn't working.
Title: Re: Drag & Drop Question
Post by: ArenMook on June 01, 2015, 07:40:29 PM
You can have a dummy object get created when you start the drag operation, with this dummy object parented to the grid. Adjust its position when you drag and call the grid's Reposition() -- it will act as you expect. Destroy this dummy game object when you stop the drag operation.