Immediate Mode Draw.Polyline working in play mode but not edit mode

Avatar
  • updated
  • Fixed

In this example Draw.Polyline only appears to draw in play mode and not edit mode, while Draw.Line works in both:

using UnityEngine;
using Shapes;

[ExecuteAlways]
public class PolylineTest : ImmediateModeShapeDrawer
{
    public bool usePolyline;
    public float thickness = 0.2f;
    public override void DrawShapes(Camera cam)
    {
        using (var path = new PolylinePath())
        using (Draw.Command(cam))
        {
            Draw.ResetAllDrawStates();
            path.AddPoint(new Vector3(0, 0, 1), thickness, Color.blue);
            path.AddPoint(new Vector3(0, 0, -1), thickness, Color.green);
            if (usePolyline)
            {
                Draw.Polyline(path, 1);
            }
            else
            {
                Draw.Line(path[0].point, path[1].point,
                    path[0].thickness, path[0].color, path[1].color);
            }
        }
    }
}

Image 286

In case it matters, I have Immediate mode instancing disabled in settings, otherwise all default.

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

fixed in 3.0.1

Avatar
Freya Holmér creator
  • Planned

looks like this happens because the polyline path is disposed outside of the draw command - if you nest the polyline path inside the draw command it'll work as expected

that said, it should be valid to structure it this way too, I'll look into fixing this!

Avatar
JohannesMP

Hmm, that makes sense, but it's still odd that it works in Play mode at all then

Avatar
Freya Holmér creator
Quote from JohannesMP

Hmm, that makes sense, but it's still odd that it works in Play mode at all then

it works in play mode because the asset is destroyed using Destroy(), but in edit mode it uses DestroyImmediate()

Avatar
Freya Holmér creator
  • Answer
  • Fixed

fixed in 3.0.1