Ejemplo n.º 1
0
        public static void AddRoundedRectLine(
            ref VertexHelper vh,
            Vector2 center,
            float width,
            float height,
            UI.GeoUtils.OutlineProperties outlineProperties,
            RoundedProperties roundedProperties,
            Color32 color,
            Vector2 uv,
            ref RoundedCornerUnitPositionData cornerUnitPositions,
            UI.GeoUtils.EdgeGradientData edgeGradientData
            )
        {
            float fullWidth  = width + outlineProperties.GetOuterDistace() * 2.0f;
            float fullHeight = height + outlineProperties.GetOuterDistace() * 2.0f;

            if (roundedProperties.Type == RoundedProperties.RoundedType.None)
            {
                Rects.AddRectRing(
                    ref vh,
                    outlineProperties,
                    center,
                    width,
                    height,
                    color,
                    uv,
                    edgeGradientData
                    );

                return;
            }

            SetCornerUnitPositions(
                roundedProperties,
                ref cornerUnitPositions
                );

            float outerRadiusMod;

            byte alpha = color.a;

            if (edgeGradientData.IsActive)
            {
                color.a = 0;

                outerRadiusMod =
                    outlineProperties.GetCenterDistace() - outlineProperties.HalfLineWeight - edgeGradientData.ShadowOffset;
                outerRadiusMod -= edgeGradientData.SizeAdd;

                AddRoundedRectVerticesRing(
                    ref vh,
                    center,
                    width,
                    height,
                    fullWidth,
                    fullHeight,
                    roundedProperties.AdjustedTLRadius,
                    roundedProperties.AdjustedTLRadius + outerRadiusMod,
                    roundedProperties.AdjustedTRRadius,
                    roundedProperties.AdjustedTRRadius + outerRadiusMod,
                    roundedProperties.AdjustedBRRadius,
                    roundedProperties.AdjustedBRRadius + outerRadiusMod,
                    roundedProperties.AdjustedBLRadius,
                    roundedProperties.AdjustedBLRadius + outerRadiusMod,
                    cornerUnitPositions,
                    color,
                    uv,
                    false
                    );

                color.a = alpha;
            }

            outerRadiusMod =
                Mathf.LerpUnclamped(
                    outlineProperties.GetCenterDistace(),
                    outlineProperties.GetCenterDistace() - outlineProperties.HalfLineWeight - edgeGradientData.ShadowOffset,
                    edgeGradientData.InnerScale);

            AddRoundedRectVerticesRing(
                ref vh,
                center,
                width,
                height,
                fullWidth,
                fullHeight,
                roundedProperties.AdjustedTLRadius,
                roundedProperties.AdjustedTLRadius + outerRadiusMod,
                roundedProperties.AdjustedTRRadius,
                roundedProperties.AdjustedTRRadius + outerRadiusMod,
                roundedProperties.AdjustedBRRadius,
                roundedProperties.AdjustedBRRadius + outerRadiusMod,
                roundedProperties.AdjustedBLRadius,
                roundedProperties.AdjustedBLRadius + outerRadiusMod,
                cornerUnitPositions,
                color,
                uv,
                edgeGradientData.IsActive
                );

            outerRadiusMod =
                outlineProperties.GetCenterDistace() +
                (outlineProperties.HalfLineWeight + edgeGradientData.ShadowOffset) * edgeGradientData.InnerScale;

            AddRoundedRectVerticesRing(
                ref vh,
                center,
                width,
                height,
                fullWidth,
                fullHeight,
                roundedProperties.AdjustedTLRadius,
                roundedProperties.AdjustedTLRadius + outerRadiusMod,
                roundedProperties.AdjustedTRRadius,
                roundedProperties.AdjustedTRRadius + outerRadiusMod,
                roundedProperties.AdjustedBRRadius,
                roundedProperties.AdjustedBRRadius + outerRadiusMod,
                roundedProperties.AdjustedBLRadius,
                roundedProperties.AdjustedBLRadius + outerRadiusMod,
                cornerUnitPositions,
                color,
                uv,
                true
                );

            if (edgeGradientData.IsActive)
            {
                outerRadiusMod =
                    outlineProperties.GetCenterDistace() +
                    outlineProperties.HalfLineWeight + edgeGradientData.ShadowOffset;
                outerRadiusMod += edgeGradientData.SizeAdd;

                color.a = 0;

                AddRoundedRectVerticesRing(
                    ref vh,
                    center,
                    width,
                    height,
                    fullWidth,
                    fullHeight,
                    roundedProperties.AdjustedTLRadius,
                    roundedProperties.AdjustedTLRadius + outerRadiusMod,
                    roundedProperties.AdjustedTRRadius,
                    roundedProperties.AdjustedTRRadius + outerRadiusMod,
                    roundedProperties.AdjustedBRRadius,
                    roundedProperties.AdjustedBRRadius + outerRadiusMod,
                    roundedProperties.AdjustedBLRadius,
                    roundedProperties.AdjustedBLRadius + outerRadiusMod,
                    cornerUnitPositions,
                    color,
                    uv,
                    true
                    );
            }
        }
Ejemplo n.º 2
0
        public static void AddRectRing(
            ref VertexHelper vh,
            UI.GeoUtils.OutlineProperties OutlineProperties,
            Vector2 center,
            float width,
            float height,
            Color32 color,
            Vector2 uv,
            ThisOtherThing.UI.GeoUtils.EdgeGradientData edgeGradientData
            )
        {
            byte alpha = color.a;

            float fullWidth  = width + OutlineProperties.GetOuterDistace() * 2.0f;
            float fullHeight = height + OutlineProperties.GetOuterDistace() * 2.0f;

            width  += OutlineProperties.GetCenterDistace() * 2.0f;
            height += OutlineProperties.GetCenterDistace() * 2.0f;

            float halfLineWeightOffset      = OutlineProperties.HalfLineWeight * 2.0f + edgeGradientData.ShadowOffset;
            float halfLineWeightInnerOffset = halfLineWeightOffset * edgeGradientData.InnerScale;

            if (edgeGradientData.IsActive)
            {
                color.a = 0;

                AddRectVertRing(
                    ref vh,
                    center,
                    width - halfLineWeightOffset - edgeGradientData.SizeAdd,
                    height - halfLineWeightOffset - edgeGradientData.SizeAdd,
                    color,
                    fullWidth,
                    fullHeight
                    );

                color.a = alpha;
            }



            AddRectVertRing(
                ref vh,
                center,
                width - halfLineWeightInnerOffset,
                height - halfLineWeightInnerOffset,
                color,
                fullWidth,
                fullHeight,
                edgeGradientData.IsActive
                );

            AddRectVertRing(
                ref vh,
                center,
                width + halfLineWeightInnerOffset,
                height + halfLineWeightInnerOffset,
                color,
                fullWidth,
                fullHeight,
                true
                );

            if (edgeGradientData.IsActive)
            {
                color.a = 0;

                AddRectVertRing(
                    ref vh,
                    center,
                    width + halfLineWeightOffset + edgeGradientData.SizeAdd,
                    height + halfLineWeightOffset + edgeGradientData.SizeAdd,
                    color,
                    fullWidth,
                    fullHeight,
                    true
                    );
            }
        }