Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started 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!
-
Bump?
-
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.
-
The problem with that is the dragged object isn't reparented, so calling the grid sort isn't working.
-
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.