public static void InitWrapContents(CustomGrid grid, List<ItemInfo> itemInfos, int countPerGroup, int curMaxCount) { if (itemInfos == null) return; var list = new List<List<ItemInfo>>(); var rows = Mathf.CeilToInt((float)itemInfos.Count / countPerGroup); var curLimitRows = Mathf.CeilToInt((float)curMaxCount / countPerGroup); for (var i = 0; i < rows; i++) { var infosContainer = new List<ItemInfo>(); for (var j = 0; j < countPerGroup; j++) { if (i * countPerGroup + j < itemInfos.Count) { infosContainer.Add(itemInfos[i * countPerGroup + j]); } } list.Add(infosContainer); } grid.Init(list, curLimitRows); }
public static void InitWrapContents(CustomGrid grid, List<HeroInfo> heroInfos, int countPerGroup, int curMaxCount) { if(heroInfos == null) { return; } var data = new List<List<long>>(); var rows = Mathf.CeilToInt((float)heroInfos.Count / countPerGroup); var curLimitRow = Mathf.CeilToInt((float)curMaxCount / countPerGroup); for (var i = 0; i < rows; i++) { var list = new List<long>(); for (var j = 0; j < countPerGroup; j++) { if (i * countPerGroup + j < heroInfos.Count) { list.Add(heroInfos[i * countPerGroup + j].Uuid); } } data.Add(list); } grid.Init(data, curLimitRow); }