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

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

            UIGradientUtils.Matrix2x3 localPositionMatrix = UIGradientUtils.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;
                byte    originalAlpha = vertex.color.a;
                vertex.color  += Color.Lerp(m_color2, m_color1, localPosition.y);
                vertex.color.a = originalAlpha;
                vh.SetUIVertex(vertex, i);
            }
        }
    }
Example #2
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (enabled)
        {
            Rect    rect = graphic.rectTransform.rect;
            Vector2 dir  = UIGradientUtils.RotationDir(m_angle);

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

            UIGradientUtils.Matrix2x3 localPositionMatrix = UIGradientUtils.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, 2.0f * m_middlePoint * localPosition.y);
                if (Mathf.Abs(localPosition.y) > 0.01f && Mathf.Abs(localPosition.y) < 0.99f || Mathf.Abs(localPosition.y) > 1.01f)
                {
                    int x = 0;
                    x++;
                }
                vh.SetUIVertex(vertex, i);
            }
        }
    }
Example #3
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (enabled)
        {
            Rect rect = graphic.rectTransform.rect;
            UIGradientUtils.Matrix2x3 localPositionMatrix = UIGradientUtils.LocalPositionMatrix(rect, Vector2.right);

            UIVertex vertex = default(UIVertex);
            for (int i = 0; i < vh.currentVertCount; i++)
            {
                vh.PopulateUIVertex(ref vertex, i);
                Vector2 normalizedPosition = localPositionMatrix * vertex.position;
                vertex.color *= UIGradientUtils.Bilerp(m_bottomLeftColor, m_bottomRightColor, m_topLeftColor, m_topRightColor, normalizedPosition);
                vh.SetUIVertex(vertex, i);
            }
        }
    }
    public override void ModifyMesh(VertexHelper vh)
    {
        if (enabled)
        {
            Rect    rect = graphic.rectTransform.rect;
            Vector2 dir  = UIGradientUtils.RotationDir(m_angle);
            UIGradientUtils.Matrix2x3 localPositionMatrix = UIGradientUtils.LocalPositionMatrix(new Rect(0f, 0f, 1f, 1f), dir);

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