Author Topic: UIDraggablePanel + DragDrop  (Read 7821 times)

kenshin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 24
    • View Profile
UIDraggablePanel + DragDrop
« on: April 16, 2012, 04:36:13 AM »
Hi,

is possible to create a draggable list of items (also only with scrollbar) that I can drag&drop on a 3D scene?

If yes, what is the best way to do that?

Thanks in advance
Kenshin

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #1 on: April 16, 2012, 09:26:05 AM »
There is an example on that... Drag & Drop. Add more items to that list, then add a scroll bar, and there you have it. :)

kenshin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #2 on: April 16, 2012, 09:40:36 AM »
I am sorry, but I need some help to do that ...  :(

Honestly, before to write this post I have tried to tweak the "Scroll View (Panel)" example adding drag&drop classes but I had some strange effects with UIDraggablePanel item managements.

Then if the best way is via "drag & drop" example is good for me, but...
how I can connect the scroll bar to the drag&drop container?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #3 on: April 16, 2012, 09:49:12 AM »
You're going about it backwards. The Drag & Drop example already has a panel in it where the widgets reside which happens to be a scroll view (clipped panel). There just aren't enough items for them to be visibly clipped. Add a couple more, and you will see. All you need to do is add a scroll bar afterwards.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #4 on: April 16, 2012, 09:50:16 AM »
To connect a scroll bar to a container, just select the UIDraggablePanel script (on the same object as the clipped UIPanel), and specify the "horizontal scroll bar" property to be your scroll bar.

kenshin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #5 on: April 16, 2012, 09:58:54 AM »
You're going about it backwards. The Drag & Drop example already has a panel in it where the widgets reside which happens to be a scroll view (clipped panel). There just aren't enough items for them to be visibly clipped. Add a couple more, and you will see. All you need to do is add a scroll bar afterwards.

Yes, I have added more items under the "DragDropContainer" game object, but I have no idea about how to link the added scroll bar to the "DragDropContainer".
I can't see any good script property, then do I must add it by coding?

Please, can you give me an example?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #6 on: April 16, 2012, 09:59:32 AM »
I just did above. o_O

kenshin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #7 on: April 16, 2012, 10:07:58 AM »
I just did above. o_O

Sorry, may be I am stupid I can find it...  :-[

You're going about it backwards. The Drag & Drop example already has a panel in it where the widgets reside which happens to be a scroll view (clipped panel). There just aren't enough items for them to be visibly clipped. Add a couple more, and you will see. All you need to do is add a scroll bar afterwards.

I have added the scroll bar widget under "ListPanel" but I am not able to link it to the "DragDropContainer".
Here I am asking your help...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #8 on: April 16, 2012, 10:28:41 AM »
To connect a scroll bar to a container, just select the UIDraggablePanel script (on the same object as the clipped UIPanel), and specify the "horizontal scroll bar" property to be your scroll bar.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #9 on: April 16, 2012, 10:29:38 AM »
If there is no UIDraggablePanel script, attach one to the UIPanel you want to be draggable.

kenshin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #10 on: April 16, 2012, 10:47:40 AM »
Yes sir, this is perfect!!!   :D
Now I understant the right way.

Just one last question:
in my UI I don't need to remove items from the container because user can drag many time the same element.
What is the best way to reach this result?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #11 on: April 16, 2012, 11:14:02 AM »
Hmm. You will want to drag a copy of the item then, not the item itself. It's a bit more complicated, but basically just make a copy via Object.Instantiate and drag that instead of the original object.

kenshin

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: UIDraggablePanel + DragDrop
« Reply #12 on: April 17, 2012, 02:28:40 AM »
Ok, I'll try!

Thanks a lot
Kenshin