Example #1
0
        public override void ModifyMesh(VertexHelper vh)
        {
            if (enabled)
            {
                Rect    rect = graphic.rectTransform.rect;
                Vector2 dir  = GradientUtils.RotationDir(m_angle);

                if (!m_ignoreRatio)
                {
                    dir = GradientUtils.CompensateAspectRatio(rect, dir);
                }

                GradientUtils.Matrix2x3 localPositionMatrix = GradientUtils.LocalPositionMatrix(rect, dir);

                UIVertex vertex = default(UIVertex);
                for (int i = 0; i < vh.currentVertCount; i++)
                {
                    vh.PopulateUIVertex(ref vertex, i);
                    Vector2 localPosition = localPositionMatrix * vertex.position;
                    vertex.color *= Color.Lerp(m_color2, m_color1, localPosition.y);
                    vh.SetUIVertex(vertex, i);
                }
            }
        }