Exemplo n.º 1
0
        public void RefreshPosition()
        {
            var lastObject = GetHighest();
            var objs       = objectPool.GetAllWithState(true);
            var index      = lastObject.CurrentIndex;
            var totalSize  = 0f;

            for (var i = 0; i < objs.Count; i++)
            {
                var currentObject = objectPool.Find(x => x.CurrentIndex == index);
                if (currentObject != null && currentObject.isUsing && currentObject.CompareTo(lastObject) != 0)
                {
                    var no = currentObject.RectTransform;
                    var lo = lastObject.RectTransform;
                    var x  = (mIsHorizontal ? lo.anchoredPosition.x + lastObject.CurrentWidth + spacing : no.anchoredPosition.x);
                    var y  = (mIsVertical ? lo.anchoredPosition.y - lastObject.CurrentHeight - spacing : no.anchoredPosition.y);
                    no.anchoredPosition = new Vector2(x, y);
                    totalSize          += mIsHorizontal ? lastObject.CurrentWidth : lastObject.CurrentHeight;
                    lastObject          = currentObject;
                }

                index++;
            }

            if (lastObject != null)
            {
                totalSize += mIsHorizontal ? lastObject.CurrentWidth : lastObject.CurrentHeight;
            }

            var canDrag = (mIsHorizontal && totalSize > ScrollRect.viewport.rect.width) || (mIsVertical && totalSize > ScrollRect.viewport.rect.height);

            ToggleScroll(canDrag);
            SetCentralizedObject();
            LimitScroll();
        }
Exemplo n.º 2
0
        public void RefreshPosition()
        {
            var lastObject = GetHighest();
            var objs       = objectPool.GetAllWithState(true);
            var index      = lastObject.currentIndex;

            for (var i = 0; i < objs.Count; i++)
            {
                var currentObject = objectPool.Find(x => x.currentIndex == index);
                if (currentObject != null && currentObject.isUsing && currentObject.CompareTo(lastObject) != 0)
                {
                    var no = currentObject.GetComponent <RectTransform>();
                    var lo = lastObject.GetComponent <RectTransform>();
                    var x  = (mIsHorizontal ? lo.anchoredPosition.x + lastObject.currentWidth + spacing : no.anchoredPosition.x);
                    var y  = (mIsVertical ? lo.anchoredPosition.y - lastObject.currentHeight - spacing : no.anchoredPosition.y);
                    no.anchoredPosition = new Vector2(x, y);

                    lastObject = currentObject;
                }

                index++;
            }
        }