/// <summary>
    /// 渲染list
    /// </summary>
    public void RenderList()
    {
        ClearList();
        float currPos = currListOffset;

        for (int i = currFirstItemIndex; i < GetListLastIndex(); i++)
        {
            ListItem item = ListPool.Instance().GetItemByType(listDatas[i].loadPath);
            item.listData = listDatas[i];
            item.ItemObj.transform.SetParent(scrollRect.content, false);
            SetRectTransform(item.ItemObj.transform as RectTransform);
            if (isHorizontal)
            {
                item.ItemObj.transform.localPosition = new Vector3(currPos, 0, 0);
            }
            else
            {
                item.ItemObj.transform.localPosition = new Vector3(0, -currPos, 0);
            }
            listItems.Add(item);
            item.BlindUI();
            currPos           = currPos + item.listData.length;
            item.ItemObj.name = i.ToString();
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 渲染list
    /// </summary>
    public void RenderList()
    {
        ClearList();
        float currPos   = currListOffset;
        int   currIndex = 0;

        for (int i = currFirstItemIndex; i <= GetListLastIndex(); i++)
        {
            ListItem item = ListPool.Instance().GetItemByType(listDatas[i].loadPath);
            item.listData = listDatas[i];
            item.ItemObj.transform.SetParent(scrollRect.content, false);
            SetRectTransform(item.ItemObj.transform as RectTransform);
            float otherLength = currIndex * listDatas[i].otherLength + currIndex * sameItemDis;
            if (isHorizontal)
            {
                item.ItemObj.transform.localPosition = new Vector3(currPos, otherLength, 0);
            }
            else
            {
                item.ItemObj.transform.localPosition = new Vector3(otherLength, -currPos, 0);
            }
//			Debug.Log(currPos);
            listItems.Add(item);
            item.BlindUI();
            item.ItemObj.name = i.ToString();
            if (currIndex < sameItemCount - 1)
            {
                currIndex++;
            }
            else
            {
                currIndex = 0;
                currPos   = currPos + item.listData.length;
            }
        }
    }