Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: i_am_kisly on May 07, 2016, 06:30:18 PM

Title: drag and drop problem
Post by: i_am_kisly on May 07, 2016, 06:30:18 PM
Hi, I have a question about №11 example. If I replace the container in a grid on the table, when you drag an item he is always in the last cell of the table. This is the first problem.
The second problem is that when I repeat the example with my Asset, the position of movable object does not coincide with the position of the cursor (mouse).
I will appreciate if I prompt solutions to these problems.
Title: Re: drag and drop problem
Post by: ArenMook on May 07, 2016, 11:40:39 PM
Pay close attention to the settings on the grid. Sorting, in particular. By default items are added to the end unless you have sorting set to something. Position-based sorting is what allows for objects to stay where they're dropped.
Title: Re: drag and drop problem
Post by: i_am_kisly on May 08, 2016, 07:06:59 PM
when I put a check to "clone on drag" I can not move the object to another container.

https://youtu.be/L5RhGckXM5o

I still do not understand why the sprite is shifted relative to the cursor. This is also seen in the video.
Title: Re: drag and drop problem
Post by: ArenMook on May 10, 2016, 06:04:23 PM
You need a custom DragDropItem script. Look inside UIDragDropItem.cs, line 320 -- it ignores most of that function is the item is "clone on drag". if you comment out line 320 and 360 it will let you drop items.

Create a custom script derived from UIDragDropItem and overwrite that function, do what you want to do inside.