Пример #1
0
        public override void Refresh()
        {
            int count = activeCells.Count;

            for (int i = 0; i < count; i++)
            {
                var cell = activeCells[i];
                RefreshCell(cell.dataIndex, cell.objIndex);
                var size = direction == FTDirection.Vertical ? cell.Height + spacing : cell.Width + spacing;
                for (int j = i + 1; j < count; j++)
                {
                    if (direction == FTDirection.Vertical)
                    {
                        activeCells[j].AnchoredPosition = new Vector2(activeCells[j].AnchoredPosition.x, activeCells[j].AnchoredPosition.y - size);
                    }
                    else
                    {
                        activeCells[j].AnchoredPosition = new Vector2(activeCells[j].AnchoredPosition.x - size, activeCells[j].AnchoredPosition.y);
                    }
                }

                if (direction == FTDirection.Vertical)
                {
                    ContentTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ContentTrans.sizeDelta.y + size);
                }
                else
                {
                    ContentTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, ContentTrans.sizeDelta.x + size);
                }
            }
        }
Пример #2
0
        bool TryAddBottom()
        {
            var downCell  = activeCells[activeCells.Count - 1];
            var downIndex = downCell.dataIndex;

            if (downIndex + 1 == cellCount)
            {
                return(false);
            }

            var cell = GetCell();

            cell.dataIndex = downIndex + 1;
            RefreshCell(cell.dataIndex, cell.objIndex);

            Vector2 pos;

            if (direction == FTDirection.Vertical)
            {
                var d1 = downCell.AnchoredPosition.y;
                var d2 = downCell.Height + spacing;
                pos = new Vector2(0.0f, d1 - d2);
                cell.CachedRectTransform.anchoredPosition = pos;
                var d3 = cell.Height + spacing;
                if (ContentTrans.sizeDelta.y <= -cell.AnchoredPosition.y + d3 * 0.5f)
                {
                    ContentTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ContentTrans.sizeDelta.y + d3);
                }
            }
            else
            {
                var d1 = downCell.AnchoredPosition.x;
                var d2 = downCell.Width + spacing;
                pos = new Vector2(d1 - d2, 0.0f);
                cell.CachedRectTransform.anchoredPosition = pos;
                var d3 = cell.Width + spacing;
                if (ContentTrans.sizeDelta.x <= -cell.AnchoredPosition.x + d3 * 0.5f)
                {
                    ContentTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, ContentTrans.sizeDelta.x + d3);
                }
            }

            activeCells.Add(cell);
            cell.gameObject.SetActive(true);
            return(true);
        }
Пример #3
0
        void TryStartAdd()
        {
            if (cellCount == 0)
            {
                return;
            }
            var cell = GetCell();

            cell.dataIndex = 0;
            RefreshCell(cell.dataIndex, cell.objIndex);
            cell.CachedRectTransform.anchoredPosition = Vector2.zero;
            if (direction == FTDirection.Vertical)
            {
                ContentTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ContentTrans.sizeDelta.y + cell.Height + spacing);
            }
            else
            {
                ContentTrans.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, ContentTrans.sizeDelta.x + cell.Width + spacing);
            }
            activeCells.Add(cell);
            cell.gameObject.SetActive(true);
        }