If not call "Draw.Command(cam)" in DrawShapes,drawing will flicker!

Avatar
  • updated
  • Fixed

I thought that when there is no content to be drawn, there is no need to call "Draw.Command(cam)"

So my code is:

public override void DrawShapes(Camera cam)
{
if (selction == null || selction.Length < 1)
{
return;
}

using (Draw.Command(cam))
{
// set up static parameters. these are used for all following Draw.Line calls

// todo 要显示在上层
Draw.ZOffsetUnits = -2;
Draw.ZOffsetFactor = 0;
Draw.Color = color;
Draw.Matrix = transform.localToWorldMatrix * coordToLocalMatrix;

foreach (var coord in selction)
{
Draw.Rectangle(new Rect(coord.x, coord.y, 1f, 1f));
}
}
}

then drawing will flicker!

then I move the return logic into `using (Draw.Command(cam))`


public override void DrawShapes(Camera cam)
{
using (Draw.Command(cam))
{
// todo 要显示在上层
Draw.ZOffsetUnits = -2;
Draw.ZOffsetFactor = 0;
Draw.Color = color;
Draw.Matrix = transform.localToWorldMatrix * coordToLocalMatrix;

if (selction != null && selction.Length >= 1)
{
foreach (var coord in selction)
{
Draw.Rectangle(new Rect(coord.x, coord.y, 1f, 1f));
}
}
}
}

problem fixed!

Reporting a bug? please specify Unity version:
2021.1.15f1c1
Reporting a bug? please specify Shapes version:
4.0.2
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Fixed

this is very likely due to a bug that has been fixed in the latest version! Feel free to open up this thread after that has been released in case it's still broken on your end :)

Avatar
Freya Holmér creator
  • Answer
  • Fixed

this is very likely due to a bug that has been fixed in the latest version! Feel free to open up this thread after that has been released in case it's still broken on your end :)