Author Topic: UIGird, UIScrollView and dragging  (Read 3320 times)

indeisoft

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
UIGird, UIScrollView and dragging
« on: January 26, 2015, 02:42:41 PM »
Hello

Im having hard times trying tring to solve some problems in making a UI for mobile using UIGrid and UIScrollView. (and UIDragScrollView,UIDragDropItem)

I tries some approaches, each time came close to solve...anyway I will explain the UI:

-I have 8 items inside UIGrid ordered horizontally.
-The UIGrid is inside a UIScrolView to enable dragging them left and right.
-order of item should not be changed
-I need also to have the option to remove items by dragging them up or down
-a very small drag(defined) should return them to their position,  a larger removes them
-there is a button -when pressed it return all the removed items (with original order)



Well I already managed putting the items in the grid,scrolling them and being able drag up and down each item .
the problems I encountered are :

1.When being dragged each item is temporary removed from the grid by the UIDragDropItem code ,than if it returned to the grid its being moved to the end- by the UIGrid.
2.To remove item from the grid mean - to loose its order , I tried remove by disabling it and using the HideInactive feature,  still it removes to the end
3.If i want to show all removed items there is no add method with position, I can remove them all and read them, however The GetChildList method which is commented to be used for removing some items is not so useful - after I change the list, How do I set it?
4.The UIScrollView stop working after some dragging item up and down - It might be because i saw the UIDragScrollView is being disabled by the UIDragDropItem  (and the colider too) , and sometimes its stayed disabled but I'm not sure
5.The UIGrid itslef is re positioned sometimes (like when all items are removed) - becoming invisible because its Y is out of the screen
I didn't figure which component re position it because its not my code
6.The UIGrid become disabled in runtime, this is OK?
7.dragging fast to the right returns the items back which is great, but to the left if there are less items than 8 (after being removed) ,its not always returns - I tried changing positions and Pivot of both the grid and the scroll.

Thank you
Tsahi

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIGird, UIScrollView and dragging
« Reply #1 on: January 27, 2015, 04:20:50 AM »
The order will be kept if you turn on Horizontal sorting. The item will be inserted where it was. Check the drag & drop example. It's the same there, except it uses Vertical sorting. Otherwise you will need to use custom sorting logic. Either way though, the way the drag & drop works by default is the item will be removed once the drag starts and placed into its own panel for the duration of the drag operation -- the panel that should be on top of everything else.

If you want to add items at a specific position, you need to either use Horizontal sorting and give items a position, or use custom sorting and write your own logic. Or just use alphabetic sorting and name items appropriately like 001, 002, etc.

UIDragDropItem disables the drag scrollview script on itself -- on the object being dragged. This is intentional, otherwise you will move the scroll view with the same action that drags the item around. Not sure why it wouldn't re-enable itself for you though. It happens in EnableDragScrollView coroutine that's called from OnDragDropRelease().

UIGrid doesn't need to stay enabled. Once its logic runs, it isn't needed anymore.

For #5 you can use UIScrollView's ResetPosition() to ensure that the content is visible.

I'm not clear on what you mean by #7.