从 List 中获取指定步长的元素,循环获取,当剩余数量不足步长时,从头开始查询遍历。不作赘述,直接展示:
public Button btn;
/// <summary>
/// 所有数据
/// </summary>
private List<int> totalList;
/// <summary>
/// 获取数据条数
/// </summary>
public int step;
/// <summary>
/// 当前页数:不需要翻页处理的,可以忽略
/// </summary>
private int PageIndex = 1;
/// <summary>
/// 起始位置
/// </summary>
private int startIndex = 0;
/// <summary>
/// Log打印使用,可以忽略
/// </summary>
private int count = 0;
/// <summary>
/// 是否超出过上限
/// </summary>
private bool isLimit = false;
void Start()
{
btn.onClick.AddListener(OnGetResult);
totalList = new List<int>();
for (int i = 0; i < 7; i++)
{
totalList.Add(i);
}