滚动列表
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AibisDream.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SizeHelper2 : MonoBehaviour, ILoopScrollSizeHelper
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
var ls = GetComponent<LoopScrollRect>();
|
||||
ls.sizeHelper = this;
|
||||
}
|
||||
|
||||
public Vector2 GetItemsSize(int itemsCount)
|
||||
{
|
||||
if (itemsCount <= 0) return new Vector2();
|
||||
int count = ScrollIndexCallback2.randomWidths.Length;
|
||||
Vector2 sum = new Vector2();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (itemsCount <= i) break;
|
||||
int t = (itemsCount - 1 - i) / count + 1;
|
||||
sum.x += t * ScrollIndexCallback2.randomWidths[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user