Skip to main content

ScrollView Variants

Important Attention Reminder

Coding Style wiki


InfiniteScrollView ships with 4 implementations (all inheriting InfiniteScrollView) — attach the matching component to the ScrollRect object and assign cellPrefab to use it; see the base class page for the shared APIs (initialization, data operations, refreshing, scrolling, and snapping).

NamespaceOxGKit.InfiniteScrollView
TypeVerticalInfiniteScrollView, HorizontalInfiniteScrollView, VerticalGridInfiniteScrollView, HorizontalGridInfiniteScrollView (all inherit InfiniteScrollView)
SourceVerticalInfiniteScrollView.cs, HorizontalInfiniteScrollView.cs, VerticalGridInfiniteScrollView.cs, HorizontalGridInfiniteScrollView.cs
using OxGKit.InfiniteScrollView;

Quick Start

Variants Overview

ImplementationLayoutSpecific Members
VerticalInfiniteScrollViewVertical list (scrolls up and down)spacing (float)
HorizontalInfiniteScrollViewHorizontal list (scrolls left and right)spacing (float)
VerticalGridInfiniteScrollViewVertical grid (scrolls up and down)spacing (Vector2), columnCount
HorizontalGridInfiniteScrollViewHorizontal grid (scrolls left and right)spacing (Vector2), rowCount
using Cysharp.Threading.Tasks;
using OxGKit.InfiniteScrollView;
using UnityEngine;

public class GridLauncher : MonoBehaviour
{
public VerticalGridInfiniteScrollView gridScrollView;

private async void Start()
{
// Grid setup (also configurable on the Inspector)
this.gridScrollView.columnCount = 4;
this.gridScrollView.spacing = new Vector2(10f, 10f);

await this.gridScrollView.InitializePool();

for (int i = 0; i < 500; i++)
this.gridScrollView.Add(new InfiniteCellData(new Vector2(100f, 100f), i));
this.gridScrollView.Refresh();
}
}

General Rules

  • The 4 implementations only differ in layout calculation and their specific members; data operations, refreshing, and snapping all share the base class behaviors.
  • The list does not configure the ScrollRect scroll axis automatically — set the ScrollRect's Vertical / Horizontal checkboxes to match the implementation you use.

Attention The grid implementations advance the layout and content-size calculation using the cellSize of the first data entry of each row/column strip, so a uniform cellSize is recommended for grids (dynamic sizes are suited to the Vertical / Horizontal lists).


VerticalInfiniteScrollView

Vertical infinite list (scrolls up and down); suited to leaderboards, chat rooms, and other vertical lists.

Typepublic class VerticalInfiniteScrollView : InfiniteScrollView
SourceVerticalInfiniteScrollView.cs
MemberDescription
public float spacingVertical spacing between cells.

Overridden Behaviors

public override void Snap(int index, float duration)
public override bool Remove(int index, bool refresh = true)
  • Snap: calculates the vertical target position by accumulating cellSize.y + spacing according to snapAlign (no-op when the content height is smaller than the viewport and cannot scroll).
  • Remove: after removal, the content position is shifted back by one cell (cellSize.y + spacing) to avoid a visual jump.

HorizontalInfiniteScrollView

Horizontal infinite list (scrolls left and right); suited to card rows, horizontal menus, and other horizontal lists.

Typepublic class HorizontalInfiniteScrollView : InfiniteScrollView
SourceHorizontalInfiniteScrollView.cs
MemberDescription
public float spacingHorizontal spacing between cells.

Overridden Behaviors

public override void Snap(int index, float duration)
public override bool Remove(int index, bool refresh = true)
  • Snap: calculates the horizontal target position by accumulating cellSize.x + spacing according to snapAlign (no-op when the content width is smaller than the viewport and cannot scroll).
  • Remove: after removal, the content position is shifted back by one cell (cellSize.x + spacing).

Reminder Tab-page (TabPage) usage can combine a horizontal list with Snap to switch pages (see the Infinite TabPage Demo in Samples, listed in the Module Intro).


VerticalGridInfiniteScrollView

Vertical grid infinite list (scrolls up and down) with columnCount cells side by side per row; suited to inventories, shops, and other grid lists.

Typepublic class VerticalGridInfiniteScrollView : InfiniteScrollView
SourceVerticalGridInfiniteScrollView.cs
MemberDescription
public Vector2 spacingCell spacing (x = horizontal, y = vertical).
public int columnCountColumn count (cells side by side per row), default 1 (values less than or equal to 0 are treated as 1).

Overridden Behaviors

public override void Snap(int index, float duration)
  • Snap: calculates the vertical target position from the row the target index belongs to (index / columnCount).

Attention columnCount was renamed from columeCount (typo fix) in v1.7.1; it is marked with FormerlySerializedAs, so serialized data of old scenes / prefabs migrates automatically.


HorizontalGridInfiniteScrollView

Horizontal grid infinite list (scrolls left and right) with rowCount cells stacked per column.

Typepublic class HorizontalGridInfiniteScrollView : InfiniteScrollView
SourceHorizontalGridInfiniteScrollView.cs
MemberDescription
public Vector2 spacingCell spacing (x = horizontal, y = vertical).
public int rowCountRow count (cells stacked per column), default 1 (values less than or equal to 0 are treated as 1).

Overridden Behaviors

public override void Snap(int index, float duration)
  • Snap: calculates the horizontal target position from the column the target index belongs to (index / rowCount).