Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: sti4thewin on April 12, 2014, 04:22:21 AM

Title: Need help with clicking on arrow to shoot to next item in scroll view
Post by: sti4thewin on April 12, 2014, 04:22:21 AM
Right now I have a scroll view with draggable icons for my color selector. What I'm trying to achieve is to let the player either drag to pick color or have the option to click on arrow to automatically move to next item in scroll view.

I have the scroll view showing only one color at a time, and the dragging is working fine. I just don't know where to start to implement a button (Arrow) that on click, springs to the next color.

btw my icons are all in a grid within the scroll view set up horizontally.
Title: Re: Need help with clicking on arrow to shoot to next item in scroll view
Post by: ArenMook on April 12, 2014, 05:05:28 AM
UICenterOnChild script has a threshold you can set (Next Page Threshold). It's used to make it possible to flick in a direction of desired movement and have it navigate to the next item (ideal usage: each item being a page). In your case you would be doing something similar. Look at how it's used in the UICenterOnChild's Recenter() function -- it calculates the closest child, then finds the second closest one in the direction of desired movement. It then centers on that second child.