滚动列表
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using AibisDream.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Demo
|
||||
{
|
||||
public class SizeHelper : MonoBehaviour, ILoopScrollSizeHelper
|
||||
{
|
||||
[HideInInspector]
|
||||
public LoopScrollRectMulti m_LoopScrollRect;
|
||||
|
||||
[HideInInspector]
|
||||
public LoopListBankBase m_LoopListBank;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
m_LoopScrollRect = GetComponent<LoopScrollRectMulti>();
|
||||
m_LoopScrollRect.sizeHelper = this;
|
||||
|
||||
m_LoopListBank = GetComponent<LoopListBankBase>();
|
||||
}
|
||||
|
||||
public Vector2 GetItemsSize(int itemsCount)
|
||||
{
|
||||
if (itemsCount <= 0) return new Vector2();
|
||||
int count = m_LoopListBank.GetListLength();
|
||||
Vector2 sum = new Vector2();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (itemsCount <= i) break;
|
||||
int t = (itemsCount - 1 - i) / count + 1;
|
||||
sum += t * m_LoopListBank.GetCellPreferredSize(i);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user