예제 #1
0
        private void RecalcSizeInternal(int axis, int vector, float paddingStart, float paddingEnd)
        {
            if (ElementPositions == null)
            {
                ElementPositions = new List <Vector2>();
            }
            ElementPositions.Clear();

            var size = Vector2.zero;

            size[axis] += paddingStart;
            for (var i = 0; i < Root.Count; ++i)
            {
                var select      = Root.UISelector(i);
                var elementSize = ElementSize[select];
                if (axis == 0)
                {
                    size[1] = Mathf.Max(size[1], elementSize[1]);
                }
                else
                {
                    size[0] = Mathf.Max(size[0], elementSize[0]);
                }
                size[axis] += elementSize[axis];
                if (i != 0 && SpecialPadding.ContainsKey(select))
                {
                    size[axis] += SpecialPadding[select];
                }
                var posx = (axis == 0)? size.x * vector - elementSize.x / 2f * vector : elementSize.x / 2f * vector;
                var posy = (axis == 1)? size.y * vector - elementSize.y / 2f * vector : elementSize.y / 2f * vector;
                ElementPositions.Add(new Vector2(posx, posy));
                if (i != Root.Count - 1)
                {
                    size[axis] += Spacing;
                }
            }
            size[axis] += paddingEnd;

            var totalSize  = RectTransform.sizeDelta;
            var parentRect = RectTransformParent.rect;

            size[axis] = Mathf.Max(size[axis], axis == 0 ? parentRect.width : parentRect.height);
            totalSize  = size;
            RectTransform.sizeDelta = totalSize;

            for (var i = 0; i < ElementPositions.Count; ++i)
            {
                ElementPositions[i] -= (size / 2f * vector);
            }
        }
예제 #2
0
        private void RecalcSizeInternal(int axis, int vector, float paddingStart, float paddingEnd)
        {
            if (ElementPositions == null)
            {
                ElementPositions = new List <float>();
            }
            ElementPositions.Clear();

            var size = 0.0f;

            size += paddingStart;
            for (var i = 0; i < Root.Count; ++i)
            {
                var select      = Root.UISelector(i);
                var elementSize = ElementSize[select];
                size += elementSize;
                if (i != 0 && SpecialPadding.ContainsKey(select))
                {
                    size += SpecialPadding[select];
                }
                ElementPositions.Add(size * vector - elementSize / 2f * vector);
                if (i != Root.Count - 1)
                {
                    size += Spacing;
                }
            }
            size += paddingEnd;

            var totalSize  = RectTransform.sizeDelta;
            var parentRect = RectTransformParent.rect;

            size                    = Mathf.Max(size, axis == 0 ? parentRect.width : parentRect.height);
            totalSize[axis]         = size;
            RectTransform.sizeDelta = totalSize;

            for (var i = 0; i < ElementPositions.Count; ++i)
            {
                ElementPositions[i] -= (size / 2f * vector);
            }
        }
예제 #3
0
 public static String ToCSSText(ElementPositions position)
 {
     return(position.ToString().Substring(9));
 }
예제 #4
0
        /// <summary>
        /// Function to write CSS text
        /// </summary>
        public static String CSSText(this ElementPositions position)
        {
            var reply = position.ToString();

            return(reply.Substring(9));
        }