- Home /
Snap to scrollview elements
I have a scroll view in Unity3D which has all of my elements in it. It scrolls only horizontally and has multiple child elements in view at any time. Most of the time this will be 6, in some rare occasions it can be 5. The setup is 2 rows of 3 objects
Example:
As you can see it's 6(and part of number 7/8) objects most of the time and in rare occasions it can be 5. (towards the end for example)
What I would like is: When dragging objects, it always snaps to 6 centered objects. So when I have 12 objects and the user drags the window a bit, I want it to snap to the closest 6. I used Unity's Scroll Rect window with a horizontal layout group below it to achieve my current result. With the settings below: Where "GameGrid" Is just an empty object with a horizontal layout group on it. Below the game grid, the game tiles are made during runtime.
watch this tutorial: https://www.youtube.com/watch?v=OsnyJNbqYXo
Answer by hameed-ullah-jan · Apr 11, 2019 at 02:23 PM
watch this tutorial: https://www.youtube.com/watch?v=OsnyJNbqYXo
That doesn't really help me. That might work fine when 1 child object is in view at a time, but it's much more diffecult when there's 6(and 2 half) objects in screen. At least I can't get it to work.
yes it isn't the exact thing that you wanted, but you can take help from this for snaping if you look at the script it is very easy to modify
Yeah I know. It's a great tutorial, but I just can't get it to work. I'm tweaking the values etc but it wont work the way I want.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Options UI over all scenes 1 Answer