上海虹口龙之梦项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

34 lines
893 B

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(RectTransform))]
[DisallowMultipleComponent]
public class EmployeeScrollView : ScrollRect
{
[SerializeField]
public RectTransform itemTemplate;
public void SetUpdateFunc<T>(List<T> list,Action<int ,GameObject> action)
{
if(itemTemplate == null)
itemTemplate = transform.Find("Item").GetComponent<RectTransform>();
ClearData();
int i = 0;
foreach (var item in list)
{
GameObject go = Instantiate(itemTemplate.gameObject,content.transform);
go.SetActive(true);
action?.Invoke(i,go);
i++;
}
}
private void ClearData()
{
foreach (Transform item in content.transform)
{
Destroy(item.gameObject);
}
}
}