Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: alexh0101 on April 04, 2015, 08:36:54 PM
-
If my scroll view has a grid of say 10 items, is there a way of knowing the the scroll view is currently centred on the nth item of the grid?
Also is there a callback function in NGUI when CenterOnChild has been executed, or do I have to do that manually?
-
wish there was a ScrollTo(rownumber)
quite often the row i'd like displayed is buried deep in the scrollview.
didnt mean to hijack the thread, but it reminded me of a mod i did to solve the above...
i ended up having a fixed position and smoothly scrolling until the desired item is locked to that position. fixed positions being the top, center and bottom of the scrollview.
-
UICenterOnChild.centeredObject tells you what it's centered over. If you aren't using UICenterOnChild, then you need to do math. Knowing UIPanel's worldCorners, use (corners[0] + corners[2]) * 0.5 to calculate the center. Now with the center in hand, run through your grid's children and figure out which one is the closest to that point.
To go to a specific child, use UICenterOnChild.CenterOn, or if you don't use it -- SpringPanel.Begin.