コード例 #1
0
    void InitTheList()
    {
        if (sampleItem != null)
        {
            float _deltaPositioning = 0.0f;
            int   _tempItemsCount   = sampleItem.parentListCapacity;

            Vector2 _tempContentSize;
            _tempContentSize = scrollContentGroup.sizeDelta;
            if (!isVerticalAlignment)
            {
                _tempContentSize.x += (sampleItem.GetComponent <RectTransform>().rect.size.x *(_tempItemsCount - 1)) + (distanceBetweenItems * (_tempItemsCount - 1));
            }
            else
            {
                _tempContentSize.y += (sampleItem.GetComponent <RectTransform>().rect.size.y *(_tempItemsCount - 1)) + (distanceBetweenItems * (_tempItemsCount - 1));
            }
            scrollContentGroup.sizeDelta = _tempContentSize;

            for (int c = 0; c < _tempItemsCount; c++)
            {
                GameObject _tempObject;
                _tempObject = (GameObject)Instantiate(sampleItem.gameObject, sampleItem.transform.position, sampleItem.transform.rotation);
                _tempObject.transform.SetParent(sampleItem.gameObject.transform.parent);
                _tempObject.name = "_" + ((c + 1).ToString());

                RectTransform _tempRect;
                _tempRect            = _tempObject.GetComponent <RectTransform>();
                _tempRect.localScale = new Vector3(1, 1, 1);
                _tempObject.GetComponent <ScrollListItem>().OnUpdateInfo(c);

                Vector3 _tempPosition;
                _tempPosition = _tempRect.localPosition;
                if (c != 0)
                {
                    _deltaPositioning += distanceBetweenItems;
                    if (!isVerticalAlignment)
                    {
                        _deltaPositioning += _tempRect.rect.size.x;
                    }
                    else
                    {
                        _deltaPositioning += _tempRect.rect.size.y;
                    }
                }
                if (!isVerticalAlignment)
                {
                    _tempPosition.x += _deltaPositioning;
                }
                else
                {
                    _tempPosition.y -= _deltaPositioning;
                }
                _tempRect.localPosition = _tempPosition;
            }
            sampleItem.gameObject.SetActive(false);
        }
    }
コード例 #2
0
ファイル: TamRecyclerView.cs プロジェクト: Tamsiree/TamKit
 /// <summary>
 /// 渲染Item
 /// </summary>
 /// <param name="item"></param>
 /// <param name="data"></param>
 /// <param name="isRefresh"></param>
 protected void OnItemRender(ScrollListItem item, object data, bool isRefresh)
 {
     if (isRefresh)
     {
         var listItem = item.GetComponent <RecyclerViewItem>();
         listItem.Refresh(data);
     }
 }
コード例 #3
0
 private void OnItemRender(ScrollListItem item, object data, bool isRefresh)
 {
     if (isRefresh)
     {
         var listItem = item.GetComponent <ListItem>();
         var listRT   = list.scrollRect.GetComponent <RectTransform>();
         var content  = string.Format("Index:{0}\nData:{1}", item.index, item.data);
         listItem.Refresh(150 + ((item.index % 15) * 20), listRT.rect.height - 40, content);
     }
 }
コード例 #4
0
    protected void OnItemRender(ScrollListItem item, object data, bool isRefresh)
    {
        if (isRefresh)
        {
            var listItem = item.GetComponent <ListItem>();
            var listRT   = list.scrollRect.GetComponent <RectTransform>();
            var content  = string.Format("Index:{0} Data:{1}", item.index, item.data);
            listItem.Refresh(listRT.rect.width - 40, 100 + ((item.index % 15) * 20), content);
        }

        //Debug.LogFormat("渲染Item [idx:{0}, value:{1}]", item.index, data);
    }