Ejemplo n.º 1
0
        internal void CacheScrollViewInfo(BaseParams parameters)
        {
            scrollViewSize = parameters.ScrollViewRT.rect.size;

            RectTransform vpRT = parameters.Viewport;
            Rect          vpRect = vpRT.rect;
            Rect          ctRect = parameters.Content.rect;
            double        ctH = ctRect.height, ctW = ctRect.width;

            if (parameters.IsHorizontal)
            {
                startEdge       = RectTransform.Edge.Left;
                endEdge         = RectTransform.Edge.Right;
                transvStartEdge = RectTransform.Edge.Top;

                hor0_vert1      = 0;
                hor1_vertMinus1 = 1;
                vpSize          = vpRect.width;
                //ctRealSize = ctW;
                paddingContentStart            = parameters.ContentPadding.left;
                paddingContentEnd              = parameters.ContentPadding.right;
                transversalPaddingContentStart = parameters.ContentPadding.top;
                itemsConstantTransversalSize   = ctH - (transversalPaddingContentStart + parameters.ContentPadding.bottom);
            }
            else
            {
                startEdge       = RectTransform.Edge.Top;
                endEdge         = RectTransform.Edge.Bottom;
                transvStartEdge = RectTransform.Edge.Left;

                hor0_vert1      = 1;
                hor1_vertMinus1 = -1;
                vpSize          = vpRect.height;
                //ctRealSize = ctH;
                paddingContentStart            = parameters.ContentPadding.top;
                paddingContentEnd              = parameters.ContentPadding.bottom;
                transversalPaddingContentStart = parameters.ContentPadding.left;
                itemsConstantTransversalSize   = ctW - (transversalPaddingContentStart + parameters.ContentPadding.right);
            }

            spacing = parameters.ContentSpacing;

            // There's no concept of content start/end padding when looping. instead, the spacing amount is appended before+after the first+last item
            if (parameters.effects.loopItems && (paddingContentStart != spacing || paddingContentEnd != spacing))
            {
                throw new OSAException(
                          "When looping is active, the content padding should be the same as content spacing. " +
                          "This is handled automatically in Params.InitIfNeeded(). " +
                          "If you overrode method, please call base's implementation first"
                          );
            }
            //paddingContentStart = paddingContentEnd = spacing;

            paddingStartPlusEnd = paddingContentStart + paddingContentEnd;
        }
Ejemplo n.º 2
0
        internal void CacheScrollViewInfo(BaseParams parameters)
        {
            scrollViewSize = parameters.ScrollViewRT.rect.size;

            RectTransform vpRT   = parameters.Viewport;
            Rect          vpRect = vpRT.rect;
            Rect          ctRect = parameters.Content.rect;

            if (parameters.IsHorizontal)
            {
                startEdge       = RectTransform.Edge.Left;
                endEdge         = RectTransform.Edge.Right;
                transvStartEdge = RectTransform.Edge.Top;

                hor0_vert1                     = 0;
                hor1_vertMinus1                = 1;
                vpSize                         = vpRect.width;
                paddingContentStart            = parameters.ContentPadding.left;
                paddingContentEnd              = parameters.ContentPadding.right;
                transversalPaddingContentStart = parameters.ContentPadding.top;
                transversalPaddingContentEnd   = parameters.ContentPadding.bottom;
            }
            else
            {
                startEdge       = RectTransform.Edge.Top;
                endEdge         = RectTransform.Edge.Bottom;
                transvStartEdge = RectTransform.Edge.Left;

                hor0_vert1                     = 1;
                hor1_vertMinus1                = -1;
                vpSize                         = vpRect.height;
                paddingContentStart            = parameters.ContentPadding.top;
                paddingContentEnd              = parameters.ContentPadding.bottom;
                transversalPaddingContentStart = parameters.ContentPadding.left;
                transversalPaddingContentEnd   = parameters.ContentPadding.right;
            }

            transversalContentSize = ctRect.size[1 - hor0_vert1];

            if (transversalPaddingContentStart == -1d || transversalPaddingContentEnd == -1d)
            {
                if (parameters.ItemTransversalSize == 0f)
                {
                    throw new OSAException(
                              "ItemTransversalSize is 0, meaning the item should fill the available space transversally, " +
                              "but the transversal padding is not specified (it's -1, which is a reserved value)"
                              );
                }

                itemsConstantTransversalSize             =
                    transversalPaddingStartPlusEnd       =
                        transversalPaddingContentStart   =
                            transversalPaddingContentEnd = -1d;
            }
            else
            {
                transversalPaddingStartPlusEnd = transversalPaddingContentStart + transversalPaddingContentEnd;
                itemsConstantTransversalSize   = transversalContentSize - transversalPaddingStartPlusEnd;
            }

            spacing = parameters.ContentSpacing;

            // There's no concept of content start/end padding when looping. instead, the spacing amount is appended before+after the first+last item
            if (parameters.effects.LoopItems && (paddingContentStart != spacing || paddingContentEnd != spacing))
            {
                throw new OSAException(
                          "When looping is active, the content padding should be the same as content spacing. " +
                          "This is handled automatically in Params.InitIfNeeded(). " +
                          "If you overrode method, please call base's implementation first"
                          );
            }

            paddingStartPlusEnd = paddingContentStart + paddingContentEnd;
        }