using asap.core; using cfg; using System.Collections.Generic; using System.Linq; using UnityEngine; public class PlayerGradeAchievement : MonoBehaviour { GameObject item; Transform content; List statisticItems = new List(); private void Awake() { item = transform.Find("ScrollView/Viewport/Content/item").gameObject; content = transform.Find("ScrollView/Viewport/Content"); item.SetActive(false); } private void Start() { List dataList = GContext.container.Resolve().TbStatistics.DataList; List dataTable = dataList.Where(x => x.Sort != 0).ToList(); dataTable.Sort((a, b) => a.Sort.CompareTo(b.Sort)); for (int i = 0; i < dataTable.Count; i += 3) { var go = Instantiate(item, content); go.SetActive(true); for (int j = 0; j < 3; j++) { StatisticItem statisticItem = go.transform.GetChild(j).GetComponent(); if (i + j < dataTable.Count) { statisticItem.Init(dataTable[i + j]); statisticItems.Add(statisticItem); } else { statisticItem.gameObject.SetActive(false); } } } } }