Author Topic: Drag and Drop  (Read 4031 times)

chetanmrane

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Drag and Drop
« on: January 23, 2014, 06:22:04 AM »
Hi,

i am trying to follow the DragDrop exanple.
I need to make some modification as mention below:

1. i want to swap an items from the list

Ex. if i drag item from left list and tried to drop it on right list item, both should get swap (reparenting both)

is it possible?

can someone guide me to correct direction?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and Drop
« Reply #1 on: January 23, 2014, 06:31:22 AM »
You get OnDragEnd() on the dragged object, and OnDrop(draggedObject) notification on the target object. Using these two notifications you can do what you want. You only need one to swap the items, but it will involve your own code.

chetanmrane

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Drag and Drop
« Reply #2 on: January 23, 2014, 07:23:49 AM »
Thanks for your reply Aren.

So what i understans till now is,

1. ExampleDragDropItem script will allow me to drag the item from second scrollview and drop it in first scrollview
2. it automatically reparent to first scrollview

my issue is, how could i reparent an item from first scrollview to second

i am still confused :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and Drop
« Reply #3 on: January 23, 2014, 07:45:06 AM »
I would suggest having a look at how I do reparenting in UIDragDropItem, line 154, 194, and 203.

ExampleDragDropItem extends this functionality, overriding the OnDragDropRelease function, and adds the ability to drop 3D items on a 3D object. Knowing what you're dragging (UICamera.currentTouch.dragged) and what you dropped it on (UICamera.hoveredObject), you can easily do the rest.