Пример #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateLayoutWithFixedSize()
        {
            int itemCount = vChildItems.Count;

            if (itemCount == 0)
            {
                return;
            }

            bool  isRev             = (Arrangement == ArrangementType.OuterToInner);
            float relSumThickness   = 0;
            float paddedOuterRadius = OuterRadius - Padding.OuterRadius;
            float paddedInnerRadius = InnerRadius + Padding.InnerRadius;
            float availDeg          = ArcDegrees - Padding.StartDegree - Padding.EndDegree;
            float availThick        = paddedOuterRadius - paddedInnerRadius - Padding.Between * (itemCount - 1);
            float innerRadius       = paddedInnerRadius;
            float paddedStartDeg    = StartingDegree + (Padding.StartDegree - Padding.EndDegree) / 2;

            Vector2 anchorPos = RendererUtil.GetRelativeAnchorPosition(RectAnchor);

            anchorPos.x *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).x);
            anchorPos.y *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).y);

            for (int i = 0; i < itemCount; i++)
            {
                HoverLayoutArcGroupChild item = vChildItems[i];
                relSumThickness += item.RelativeThickness;
            }

            for (int i = 0; i < itemCount; i++)
            {
                int childI = (isRev ? itemCount - i - 1 : i);
                HoverLayoutArcGroupChild item = vChildItems[childI];
                ILayoutableArc           elem = item.Elem;
                float elemRelThick            = availThick * item.RelativeThickness / relSumThickness;
                float elemRelArcDeg           = availDeg * item.RelativeArcDegrees;
                float radiusOffset            = elemRelThick * item.RelativeRadiusOffset;
                float elemStartDeg            = paddedStartDeg + elemRelArcDeg * item.RelativeStartDegreeOffset;

                elem.SetArcLayout(
                    innerRadius + elemRelThick + radiusOffset,
                    innerRadius + radiusOffset,
                    elemRelArcDeg,
                    this
                    );

                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".x", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".y", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);

                Vector3 localPos = elem.transform.localPosition;
                localPos.x = anchorPos.x;
                localPos.y = anchorPos.y;

                elem.transform.localPosition = localPos;
                elem.transform.localRotation = Quaternion.AngleAxis(elemStartDeg, Vector3.back);

                innerRadius += elemRelThick + Padding.Between;
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateLayoutWithFixedSize()
        {
            int itemCount = vChildItems.Count;

            if (itemCount == 0)
            {
                return;
            }

            bool  isRev             = (Arrangement == ArrangementType.Reverse);
            float degSumPad         = DegreePadding * (itemCount - 1);// + RadiusPadding*2;
            float relSumArcDeg      = 0;
            float paddedOuterRadius = OuterRadius - RadiusPadding;
            float paddedInnerRadius = InnerRadius + RadiusPadding;
            float availDeg          = ArcDegrees - degSumPad;
            float deg = StartingDegree - ArcDegrees / 2;

            Vector2 anchorPos = RendererUtil.GetRelativeAnchorPosition(RectAnchor);

            anchorPos.x *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).x);
            anchorPos.y *= (vRectSize == null ? OuterRadius * 2 : ((Vector2)vRectSize).y);

            for (int i = 0; i < itemCount; i++)
            {
                HoverLayoutArcGroupChild item = vChildItems[i];
                relSumArcDeg += item.RelativeArcDegrees;
            }

            for (int i = 0; i < itemCount; i++)
            {
                int childI = (isRev ? itemCount - i - 1 : i);
                HoverLayoutArcGroupChild item = vChildItems[childI];
                ILayoutableArc           elem = item.Elem;
                float elemRelDeg    = availDeg * item.RelativeArcDegrees / relSumArcDeg;
                float relInset      = (paddedOuterRadius - paddedInnerRadius) * (1 - item.RelativeThickness) / 2;
                float elemThick     = paddedOuterRadius - paddedInnerRadius - relInset * 2;
                float elemRelArcDeg = availDeg * item.RelativeArcDegrees;
                float radiusOffset  = elemThick * item.RelativeRadiusOffset;
                float elemStartDeg  = deg + elemRelDeg / 2 +
                                      elemRelArcDeg * item.RelativeStartDegreeOffset;

                elem.SetArcLayout(
                    paddedOuterRadius - relInset + radiusOffset,
                    paddedInnerRadius + relInset + radiusOffset,
                    elemRelDeg,
                    this
                    );

                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".x", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalPosition + ".y", this);
                elem.Controllers.Set(SettingsControllerMap.TransformLocalRotation, this);

                Vector3 localPos = elem.transform.localPosition;
                localPos.x = anchorPos.x;
                localPos.y = anchorPos.y;

                elem.transform.localPosition = localPos;
                elem.transform.localRotation = Quaternion.AngleAxis(elemStartDeg, Vector3.back);

                deg += elemRelDeg + DegreePadding;
            }
        }