public void SetLayoutHorizontal()
        {
            BigListView   bigListView = bigListViewGameObject.GetComponent <BigListView> ();
            RectTransform bigListViewRectTransform = (bigListViewGameObject.transform as RectTransform);
            RectTransform contentRectTransform     = this.GetComponent <RectTransform> ();

            switch (bigListView.direction)
            {
            case BigListView.Direction.Horizontal: {
                for (int childIndex = 0; childIndex < this.transform.childCount; childIndex++)
                {
                    RectTransform            itemContainerTransform = this.transform.GetChild(childIndex) as RectTransform;
                    BigListViewItemContainer itemContainer          = itemContainerTransform.GetComponent <BigListViewItemContainer> ();

                    itemContainerTransform.anchorMin = new Vector2(0, 1);
                    itemContainerTransform.anchorMax = new Vector2(0, 1);

                    itemContainerTransform.offsetMin = new Vector2(bigListView.GetItemPosition(itemContainer.itemIndex), -bigListViewRectTransform.rect.height);
                    itemContainerTransform.offsetMax = new Vector2(bigListView.GetItemPosition(itemContainer.itemIndex) + bigListView.GetItemSize(itemContainer.itemIndex), 0);
                }

                break;
            }
            }
        }
Esempio n. 2
0
        private void _updateItems()
        {
            // TODO
            int minDisplayItemIndex = -1;
            int maxDisplayItemIndex = -1;

            for (int itemIndex = 0; itemIndex < this.items; itemIndex++)
            {
                bool displayItem = this._isItemInDisplaySegment(itemIndex);
                if (displayItem)
                {
                    if (minDisplayItemIndex < 0)
                    {
                        minDisplayItemIndex = itemIndex;
                    }
                    else
                    {
                        minDisplayItemIndex = Mathf.Min(minDisplayItemIndex, itemIndex);
                    }

                    if (maxDisplayItemIndex < 0)
                    {
                        maxDisplayItemIndex = itemIndex;
                    }
                    else
                    {
                        maxDisplayItemIndex = Mathf.Max(maxDisplayItemIndex, itemIndex);
                    }
                }
            }

//			Debug.Log (" @ BigListView._updateItems(): " + this._displaySegmentHead + " -> " + this._displaySegmentTail);
//			Debug.Log (" @ BigListView._updateItems(): [" + minDisplayItemIndex + ", " + maxDisplayItemIndex + "]");

            bool[] cacheStatus = new bool[2 * this._itemCacheSize + (maxDisplayItemIndex - minDisplayItemIndex) + 1];

            for (int childIndex = 0; childIndex < this._contentPanel.transform.childCount; childIndex++)
            {
                GameObject itemContainerGameObject = this._contentPanel.transform.GetChild(childIndex).gameObject;
                if (itemContainerGameObject.activeSelf)
                {
                    BigListViewItemContainer itemContainer = itemContainerGameObject.GetComponent <BigListViewItemContainer> ();
                    if (itemContainer.itemIndex < minDisplayItemIndex - this._itemCacheSize || itemContainer.itemIndex > maxDisplayItemIndex + this._itemCacheSize)
                    {
                        this._freeItemContainer(itemContainerGameObject);
//						Debug.Log (" @ BigListView._free(" + itemContainer.itemIndex + ")");
                    }
                    else
                    {
                        cacheStatus [itemContainer.itemIndex - (minDisplayItemIndex - this._itemCacheSize)] = true;
                    }
                }
            }

            for (int itemIndex = minDisplayItemIndex - this._itemCacheSize; itemIndex <= maxDisplayItemIndex + this._itemCacheSize; itemIndex++)
            {
                if (itemIndex >= 0 && itemIndex <= this.items - 1 && !cacheStatus [itemIndex - (minDisplayItemIndex - this._itemCacheSize)])
                {
                    GameObject itemContainerGameObject     = this._allocItemContainer();
                    BigListViewItemContainer itemContainer = itemContainerGameObject.GetComponent <BigListViewItemContainer> ();
//					Debug.Log (" @ BigListView._alloc(" + itemIndex + "): prev: " + itemContainer.itemIndex);
                    itemContainer.itemIndex = itemIndex;
                    this.bigListViewDelegate.GetItem(itemContainerGameObject, itemIndex);
                }
            }
        }