Support => NGUI 3 Support => Topic started by: soofaloofa on April 18, 2012, 06:04:27 PM
Title: UIDraggablePanel Snapping to item
Post by: soofaloofa on April 18, 2012, 06:04:27 PM
Hi,
I have a grid contained within a UIDraggablePanel. My goal is to have the draggable panel focus on a specific element in the grid programmatically. Any advice?
I'm looking at the UIDraggablePanel.SetDragAmount function and thinking I could calculate the total number of items in my grid and the position of the item I want to focus; then taking this as a percentage pass the value to SetDragAmount.
Is there a better way?
Kevin
Title: Re: UIDraggablePanel Snapping to item
Post by: ArenMook on April 18, 2012, 08:27:22 PM
The snapping to items is an often-requested feature that I'll add in a future update, but for now you can indeed achieve what you want by using SetDragAmount.
Title: Re: UIDraggablePanel Snapping to item
Post by: soofaloofa on May 05, 2012, 01:58:17 PM
Hi,
Any update on adding this to NGUI. I'm debating whether to start programming this on my own or wait for a future NGUI update.
Thanks,
Kevin
Title: Re: UIDraggablePanel Snapping to item
Post by: ArenMook on May 05, 2012, 02:23:57 PM
I haven't done any work on this yet.
Title: Re: UIDraggablePanel Snapping to item
Post by: soofaloofa on May 11, 2012, 12:25:20 PM
I started my implementation and have a quick question. I've calculated the position of each of my pages as a percentage of the draggable panel size.
scrollBar.scrollValue= scrollAmount;// scrollbar is set to a UIScrollbar component
This works great to reposition my draggable panel on the desired child transform. What I want to do is LERP the UIScrollbar.scrollValue so that the transition to the next position is done smoothly.
Could you provide an example of how this would be done?
Thanks again!
Title: Re: UIDraggablePanel Snapping to item
Post by: ArenMook on May 11, 2012, 02:49:56 PM
Not sure I understand the complexity in this... just have some script (or write a tweener) interpolate from A to B, and update the scroll bar's scrollValue.
Title: Re: UIDraggablePanel Snapping to item
Post by: soofaloofa on May 11, 2012, 03:39:02 PM
Yes that's exactly what I would like to do. I just don't understand Lerp functions that well. I'll read up on it and try it out.