Author Topic: drag and drop problem  (Read 4473 times)

i_am_kisly

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
drag and drop problem
« 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: drag and drop problem
« Reply #1 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.

i_am_kisly

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: drag and drop problem
« Reply #2 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.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: drag and drop problem
« Reply #3 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.