InfiniteScroll

The InfiniteScroll script must be attached to a ScrollRect with Movement Type set to Unrestricted and only Horizontal or Vertical checked. We want the content to run free but not in every direction.

Scroll Rect with unrestricted movement

The InfiniteScroll script has a reference to the Content of the ScrollRect and another one to a Prefab used to create the content elements.

Reference to Content

Let’s review all the properties:

  • Reposition Speed: The speed that the scroll uses when it detects a selection. The selection can be invoked by a click or by a deceleration. Default is 10.

  • Item Width: The width of the objects inside the scroll.

  • Item Height: The height of the objects inside the scroll.

  • Scroll Move Sensivity: This is a threshold used to detect motion of the scroll content. The higher it is the harder is to consider a movement a movement. It’s mainly used when a item is touched to avoid subtle motion to be detected as a movement.

  • Item Offset: When using positive values the items will be moved up (horizontal scroll) or right (vertical scroll). It allows you to adjust the items’ position.

  • Content Offset: Similar to the Item Offset but this time when using positive values the content will move right (horizontal scroll) and up(vertical scroll). Take into account that moving this parameter can cause that your content is not being properly shown.

  • Selection Offset: By default the central item is the one which is considered to be selected. If you want to change this behaviour then you should use this property to move the selected item right or left on the horizontal scrolls and up and down on the vertical ones. i.e. if you have a horizontal scroll with 3 elements and you want the left one to be the selection then you should put a -1 in this parameter. If you put a 1 then the right one will be the selection.

  • Is Vertical: Vertical or Horizontall scroll. Remember to set it too in the ScrollRect.

  • Invert Order: Inverts the order of the datasource.

  • Keep 1Scale For Items: Removed in last version.

  • Refresh Equality Comparer On DataSource Set: The first time a datasource is set the control will look for the IEquatable interface in your item (model) class. If it finds it, it will use it to decide which is the selected item. If not, it will use IndexOf method (from List class) . In order to avoid overloading everytime you make a selection this parameter is set to false. If you foresee that you’re not going to change the datasource and the datasource items’ class then this will work good for you. On the other hand, if you know that your datasource item’s class will change (first you fill it with apples and then with pears) then you will have to set this flag to true.

  • Content: The content object that will hold all the elements. This object is mandatory and the script won’t work without it.

  • Item Prefab: The prefab representing each of the objects/elements. This object is mandatory and the script won’t work without it.