Polygon Gradient Fill in Immediate mode?

Avatar
  • updated
  • Answered

Is it possible to add a gradient fill to a polygon while using Immediate mode?

There isn't a parameter for it just Color.  Setting the Draw.GradientFill beforehand does nothing.

For example: 

//coordinates are in the 0-1 range, gradient should go from cyan to black.

using( Draw.Command( cam ) )
{
    Draw.GradientFillType = FillType.LinearGradient;
var gf = new GradientFill();
    gf.colorStart = Color.cyan;
    gf.colorEnd = Color.black;
    gf.linearStart = new Vector3(0, 1, 0);
    gf.linearEnd = new Vector3(0, 0, 0);
    Draw.GradientFill = gf;
    Draw.Polygon(pgpath); }
Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
URP
Avatar
Freya Holmér creator
  • Answered

You'll also need to set 

Draw.UseGradientFill = true;

and then you should be good to go!