Пример #1
0
    /// <summary>
    /// 计算显示cell需要的数据,按行存储
    /// </summary>
    /// <param name="beginIndex">开始计算的cell索引</param>
    /// <param name="source">数据源</param>
    public void fillData(int beginIndex, List <GridDataSource> source)
    {
        float tempPosY = padding.top;

        for (int i = beginIndex; i < source.Count; i++)
        {
            GridDataSource data = source[i];
            WllTemplate    wllt = itemTemplate.GetWllItemTemplate(data.templateId);

            LineData ld          = GetLine(tempPosY, i, wllt.height);
            float    heightDelta = 0;
            bool     addSucess   = ld.AddCell(data, i, wllt, this, ref heightDelta);
            if (!addSucess)
            {
                //滑动位置
                tempPosY = tempPosY + ld.lineHeight + padding.spacey;
                //新增一行
                ld = LineData.NewLine(tempPosY, i, wllt.height);

                addSucess = ld.AddCell(data, i, wllt, this, ref heightDelta);
                if (!addSucess)
                {
                    Debug.LogError("Item的大小不合适窗口的大小");
                    break;
                }
                else
                {
                    lineDataList.Add(ld);
                }
            }
        }
        //控制content的长度
        LineData last = lineDataList[lineDataList.Count - 1];

        ContentHeight = last.childLineY + last.lineHeight + padding.bottom;
    }