Пример #1
0
        /// <summary>
        /// Set element size.
        /// </summary>
        /// <param name="element">Element.</param>
        public void SetElementSize(LayoutElementInfo element)
        {
            var driven_properties = DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.AnchoredPositionZ;

            if (ChildrenWidth != ChildrenSize.DoNothing)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaX;
                element.Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, element.NewWidth);
            }

            if (ChildrenHeight != ChildrenSize.DoNothing)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaY;
                element.Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, element.NewHeight);
            }

            if (LayoutType == LayoutTypes.Ellipse || ResetRotation)
            {
                driven_properties            |= DrivenTransformProperties.Rotation;
                element.Rect.localEulerAngles = element.NewEulerAngles;
            }

            if (LayoutType == LayoutTypes.Ellipse)
            {
                driven_properties |= DrivenTransformProperties.Pivot;
                element.Rect.pivot = element.NewPivot;
            }

            propertiesTracker.Add(this, element.Rect, driven_properties);
        }
Пример #2
0
        /// <summary>
        /// Get aligned height.
        /// </summary>
        /// <param name="element">Element.</param>
        /// <param name="maxHeight">Maximum height.</param>
        /// <param name="cellMaxSize">Max size of the cell.</param>
        /// <param name="emptyHeight">Height of the empty space.</param>
        /// <returns>Aligned height.</returns>
        protected override Vector2 GetAlignByHeight(LayoutElementInfo element, float maxHeight, Vector2 cellMaxSize, float emptyHeight)
        {
            var cell_align = GroupPositions[(int)Layout.CellAlign];

            return(new Vector2(
                       (cellMaxSize.x - element.Width) * cell_align.x,
                       (maxHeight - element.Height) * (1 - cell_align.y)));
        }
Пример #3
0
        void SetInitialSize(LayoutElementInfo element, Vector2 max_size)
        {
            if (Layout.ChildrenWidth != ChildrenSize.DoNothing)
            {
                element.NewWidth = (max_size.x != -1f) ? max_size.x : element.PreferredWidth;
            }

            if (Layout.ChildrenHeight != ChildrenSize.DoNothing)
            {
                element.NewHeight = (max_size.y != -1f) ? max_size.y : element.PreferredHeight;
            }
        }
Пример #4
0
        void InsertToBlock(int block_index, LayoutElementInfo element)
        {
            for (int i = ElementsGroup.Count; i <= block_index; i++)
            {
                ElementsGroup.Add(new List <LayoutElementInfo>());
            }

            var row = ElementsGroup[block_index];

            row.Add(element);

            BlocksSizes[block_index] += element.AxisSize;
            if (row.Count > 1)
            {
                var spacing = Layout.IsHorizontal ? Layout.Spacing.x : Layout.Spacing.y;
                BlocksSizes[block_index] += spacing;
            }
        }
Пример #5
0
        /// <summary>
        /// Set element size.
        /// </summary>
        /// <param name="element">Element.</param>
        public void SetElementSize(LayoutElementInfo element)
        {
            var driven_properties = DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.AnchoredPositionZ;

            if (element.ChangedWidth)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaX;
                element.Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, element.NewWidth);
            }

            if (element.ChangedHeight)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaY;
                element.Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, element.NewHeight);
            }

            if (element.ChangedWidth || element.ChangedHeight)
            {
                propertiesTracker.Add(this, element.Rect, driven_properties);
            }
        }
Пример #6
0
 /// <summary>
 /// Get aligned height.
 /// </summary>
 /// <param name="element">Element.</param>
 /// <param name="maxHeight">Maximum height.</param>
 /// <param name="cellMaxSize">Max size of the cell.</param>
 /// <param name="emptyHeight">Height of the empty space.</param>
 /// <returns>Aligned height.</returns>
 protected override Vector2 GetAlignByHeight(LayoutElementInfo element, float maxHeight, Vector2 cellMaxSize, float emptyHeight)
 {
     return(new Vector2(
                (cellMaxSize.x - element.Width) * InnerAligns[(int)Layout.InnerAlign],
                emptyHeight * RowAligns[(int)Layout.RowAlign]));
 }
Пример #7
0
 /// <summary>
 /// Get aligned width.
 /// </summary>
 /// <param name="element">Element.</param>
 /// <param name="maxWidth">Maximum width.</param>
 /// <param name="cellMaxSize">Max size of the cell.</param>
 /// <param name="emptyWidth">Width of the empty space.</param>
 /// <returns>Aligned width.</returns>
 protected override Vector2 GetAlignByWidth(LayoutElementInfo element, float maxWidth, Vector2 cellMaxSize, float emptyWidth)
 {
     return(new Vector2(
                emptyWidth * RowAligns[(int)Layout.RowAlign],
                (cellMaxSize.y - element.Height) * InnerAligns[(int)Layout.InnerAlign]));
 }
 /// <summary>
 /// Get aligned height.
 /// </summary>
 /// <param name="element">Element.</param>
 /// <param name="maxHeight">Maximum height.</param>
 /// <param name="cellMaxSize">Max size of the cell.</param>
 /// <param name="emptyHeight">Height of the empty space.</param>
 /// <returns>Aligned height.</returns>
 protected abstract Vector2 GetAlignByHeight(LayoutElementInfo element, float maxHeight, Vector2 cellMaxSize, float emptyHeight);
 /// <summary>
 /// Get aligned width.
 /// </summary>
 /// <param name="element">Element.</param>
 /// <param name="maxWidth">Maximum width.</param>
 /// <param name="cellMaxSize">Max size of the cell.</param>
 /// <param name="emptyWidth">Width of the empty space.</param>
 /// <returns>Aligned width.</returns>
 protected abstract Vector2 GetAlignByWidth(LayoutElementInfo element, float maxWidth, Vector2 cellMaxSize, float emptyWidth);