Author Topic: Drag and drop between two scrollable windows  (Read 3925 times)

UnityJP

  • Guest
Drag and drop between two scrollable windows
« on: September 26, 2012, 11:48:19 AM »
Hi,

On Android I'm trying to setup a system where I have two scrollable views (using the UIViewport and UIDragCamera) that contain objects which I want to drag and drop between.  I want to make sure I'm theoretically setting this up correctly while I go down this path.

So I will have two windows (using a UITiledSprite) that each have a UIDragCamera, DragDropContainer and collider attached to them.  I also have two UIGrids that house the objects that will be dragged.  Each object that is being dragged has a collider and DragDropItem attached to them.  The DragDropRoot is located on just an empty game object in the scene.

I am currently drilling down this path right now but I wanted to see if anyone sees a flaw in my design, know of an easier way to accomplish this, or just have any gotchas they've run into while trying to accomplish a similar thing

Thanks,
JP

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and drop between two scrollable windows
« Reply #1 on: September 26, 2012, 01:05:51 PM »
The only question I can ask is how will you know when you're supposed to be scrolling the window, and when you're supposed to start drag & drop?

UnityJP

  • Guest
Re: Drag and drop between two scrollable windows
« Reply #2 on: September 26, 2012, 02:48:20 PM »
I had similar concerns when this concept was assigned to me and still have doubts about whether this will flow properly but the solution (as it was explained to me) is the user would have to hold down on the object for a few seconds and it would "pop out" then be able to be dragged.

The setup I described is working well (without the fix for scrolling vs dragging) but its caused me to run into another issue.  In my scroll view, since I added colliders to the objects inside, the scroll view only scrolls when I don't hit the collider of the objects inside with my click.  At first this made sense to me since the object collider would prevent the window's collider from getting the click. But they are on different layers, shouldn't it scroll anyways since the UICamera's event receiver mask is set to the window's layer and not the objects?

Thanks in advance

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drag and drop between two scrollable windows
« Reply #3 on: September 26, 2012, 08:15:46 PM »
Colliders on items are intercepting your events. You will want to add the same UIDragCamera script to them as well.