Пример #1
0
        protected override void OnPopulateMesh(VertexHelper vh)
        {
            vh.Clear();

            Rect pixelRect = RectTransformUtility.PixelAdjustRect(rectTransform, canvas);

            RoundedProperties.UpdateAdjusted(pixelRect, 0.0f);
            AntiAliasingProperties.UpdateAdjusted(canvas);
            OutlineProperties.UpdateAdjusted();
            ShadowProperties.UpdateAdjusted();

            // draw fill shadows
            if (ShadowProperties.ShadowsEnabled)
            {
                if (ShapeProperties.DrawFill && ShapeProperties.DrawFillShadow)
                {
                    for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                    {
                        edgeGradientData.SetActiveData(
                            1.0f - ShadowProperties.Shadows[i].Softness,
                            ShadowProperties.Shadows[i].Size,
                            AntiAliasingProperties.Adjusted
                            );

                        ShapeUtils.RoundedRects.AddRoundedRect(
                            ref vh,
                            ShadowProperties.GetCenterOffset(pixelRect.center, i),
                            pixelRect.width,
                            pixelRect.height,
                            RoundedProperties,
                            ShadowProperties.Shadows[i].Color,
                            GeoUtils.ZeroV2,
                            ref unitPositionData,
                            edgeGradientData
                            );
                    }
                }
            }

            if (ShadowProperties.ShowShape && ShapeProperties.DrawFill)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                ShapeUtils.RoundedRects.AddRoundedRect(
                    ref vh,
                    pixelRect.center,
                    pixelRect.width,
                    pixelRect.height,
                    RoundedProperties,
                    ShapeProperties.FillColor,
                    GeoUtils.ZeroV2,
                    ref unitPositionData,
                    edgeGradientData
                    );
            }

            if (ShadowProperties.ShadowsEnabled)
            {
                // draw outline shadows
                if (ShapeProperties.DrawOutline && ShapeProperties.DrawOutlineShadow)
                {
                    for (int i = 0; i < ShadowProperties.Shadows.Length; i++)
                    {
                        edgeGradientData.SetActiveData(
                            1.0f - ShadowProperties.Shadows[i].Softness,
                            ShadowProperties.Shadows[i].Size,
                            AntiAliasingProperties.Adjusted
                            );

                        ShapeUtils.RoundedRects.AddRoundedRectLine(
                            ref vh,
                            ShadowProperties.GetCenterOffset(pixelRect.center, i),
                            pixelRect.width,
                            pixelRect.height,
                            OutlineProperties,
                            RoundedProperties,
                            ShadowProperties.Shadows[i].Color,
                            GeoUtils.ZeroV2,
                            ref unitPositionData,
                            edgeGradientData
                            );
                    }
                }
            }

            // fill
            if (ShadowProperties.ShowShape && ShapeProperties.DrawOutline)
            {
                if (AntiAliasingProperties.Adjusted > 0.0f)
                {
                    edgeGradientData.SetActiveData(
                        1.0f,
                        0.0f,
                        AntiAliasingProperties.Adjusted
                        );
                }
                else
                {
                    edgeGradientData.Reset();
                }

                ShapeUtils.RoundedRects.AddRoundedRectLine(
                    ref vh,
                    pixelRect.center,
                    pixelRect.width,
                    pixelRect.height,
                    OutlineProperties,
                    RoundedProperties,
                    ShapeProperties.OutlineColor,
                    UI.GeoUtils.ZeroV2,
                    ref unitPositionData,
                    edgeGradientData
                    );
            }
        }