Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    protected virtual void ProcessMoveLast()
    {
        ScrollBehaviour firstRect = null;
        ScrollBehaviour item      = null;

        this.tempList.Clear();
        for (int i = 0; i < this.infiniteItems.Count; i++)
        {
            this.tempList.Add(this.infiniteItems[i]);
        }

        firstRect = this.tempList[0];
        for (int i = this.tempList.Count - 1; i >= 0; i--)
        {
            item = this.tempList[i];
            var able = this.moveLastable && CanMoveLast(this.align, item);
            if (able)
            {
                this.infiniteItems.Remove(item);
                this.infiniteItems.Insert(0, item);
                var offset = CalculateElementOffset(this.align);
                item.rectTransform.anchoredPosition = firstRect.rectTransform.anchoredPosition - offset;
                firstRect = item;
                this.hostIndex--;
                this.preIndex--;
                item.Dispose();
                item.Display(this.datas[this.preIndex]);
            }
            else
            {
                break;
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        this.m_scroll = this.transform.FindChild("ScrollBar").GetComponent<ScrollBehaviour>();
        this.m_list = this.transform.FindChild("ListContentElts");
        this.m_offsetTarget = this.m_list.position;

        int steps = this.m_list.childCount / m_elementsByLine - 1;
        if(steps == 0){
            this.m_scroll.gameObject.SetActive(false); // on cache la barre de scrolling, elle ne sert à rien
        }
        else{
            this.m_scroll.Steps = steps;
        }
        this.m_animationTime = this.m_speed;
    }
Ejemplo n.º 3
0
    protected virtual void ProcessMoveNext()
    {
        ScrollBehaviour lastRect = null;
        ScrollBehaviour item     = null;

        this.tempList.Clear();
        for (int i = 0; i < this.infiniteItems.Count; i++)
        {
            this.tempList.Add(this.infiniteItems[i]);
        }
        if (this.tempList.Count <= 0)
        {
            return;
        }
        lastRect = this.tempList[this.tempList.Count - 1];
        for (int i = 0; i < this.tempList.Count; i++)
        {
            item = this.tempList[i];
            var able = this.moveNextable && CanMoveNext(this.align, item);
            if (able)
            {
                this.infiniteItems.Remove(item);
                this.infiniteItems.Add(item);
                var offset = CalculateElementOffset(this.align);
                item.rectTransform.anchoredPosition = lastRect.rectTransform.anchoredPosition + offset;
                lastRect = item;

                this.hostIndex++;
                this.preIndex++;
                item.Dispose();
                item.Display(this.datas[this.hostIndex]);
            }
            else
            {
                break;
            }
        }
    }
Ejemplo n.º 4
0
    private bool CanMoveLast(Align _align, ScrollBehaviour _item)
    {
        var itemMinPosition = _item.rectTransform.GetMinReferencePosition(this.rectTransform);
        var itemMaxPosition = _item.rectTransform.GetMaxReferencePosition(this.rectTransform);

        switch (_align)
        {
        case Align.Left:
            return(itemMinPosition.x > this.maxOffset.x);

        case Align.Bottom:
            return(itemMinPosition.y > this.maxOffset.y);

        case Align.Right:
            return(itemMaxPosition.x < this.minOffset.x);

        case Align.Top:
            return(itemMaxPosition.y < this.minOffset.y);

        default:
            return(false);
        }
    }