yyl
昨天 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
 
    public class CommonGetItemCell : CellView
    {
        [SerializeField] List<CommonGetItem> commonGetItems = new List<CommonGetItem>();
        [SerializeField] HorizontalLayoutGroup horizontalLayout;
        public void Display(int rowIndex)
        {
            var dict = ItemLogicUtility.Instance.totalShowItems;
            var list = dict.Keys.ToList();
            int rowCount = (int)Mathf.Ceil((float)list.Count / 5);
            horizontalLayout.childAlignment= rowCount > 1?TextAnchor.MiddleLeft: TextAnchor.MiddleCenter;
 
            for (int i = 0; i < commonGetItems.Count; i++)
            {
                int index = rowIndex * 5 + i;
                if (index < list.Count)
                {
                    int itemId = list[index];
                    commonGetItems[i].Display(itemId);
                    commonGetItems[i].SetActive(true);
                }
                else
                {
                    commonGetItems[i].SetActive(false);
                }
            }
        }
    }