Project level:
Scrollviewbg is the background image of 600x150. The Inspector view is as follows:
Panel is the parent container of scrollview. The size is 600x150. The Inspector view is as follows:
Item is each item in the scrollview. The size is 200x150. The Inspector view is as follows:
The above additional scripts are all set by default. The effect of running the program is as follows:
We can see that the images that do not need to be displayed are not hidden. The solution is to set the clipping of uipanel in the panel and set this item to soft clip! Running effect:
If you want to achieve this: when you drag to the last image, you can play the first image instead of leaving it. This is equivalent to concatenating these images into a circle, in this case, we only need to add a uiwrap content script to the Panel. The item width is the width of each item. The width of each item here is 200, so I set it to 200. Do not check the cull content, when checked, the effect is as follows:
However, when you use the uiwrap content script, a problem occurs: when the program is not running, each item is displayed in the order of 1, 2, 3, 4, 5, where 4 is hidden, the program runs on 1, 2, and 3.
However, when the program runs, it does display 5, 2, and 3. If you want to display 1, 2, and 3, you must place 1 at 5 and 2 at 1, 3. Place it at the location of 2!
The following describes how cull content is selected:
Let's take a look at the running effect when checked. If you don't understand an option, you can see the difference when running the program:
It can be seen from the availability that the picture is not played in a circle, but is displayed blank, and you can drag only when you click each item, because only the uidrag scroll view drag script is added to each item, if you want to drag the blank area of the background, you can move each item to the left or right. In this case, you only need to add a uidrag scroll view and box collider to scrollviewbg, and set the scroll view of the uidrag scroll View Script to panel!
The effect is as follows:
You can also set it to vertical sliding or custom sliding. You only need to set the movement option of the uiscroll View Script!
Usage and notes of uiscroll View