Polyline not working in Immediate Mode for URP

  • updated

Polyline works fine on BiRP for me, but nothing appears for URP. It works fine via the component, but nothing is visible when drawing one in immediate mode.

The IM Monitor reports the polyline material is in use and that its mesh is in the pool (but unused?)

Image 788

I stepped through the Shapes render pass and the draw call looks like its being added to the command buffer.

Image 789

I tried toggling GPU Instancing, reinstalling, restarting, regenerating shaders/materials, changing join mode etc but had no luck.

Here's the simple test script

public class PolyLineTest : ImmediateModeShapeDrawer
public override void DrawShapes(Camera cam)
using (Draw.Command(cam))
Draw.Matrix = transform.localToWorldMatrix;
using var path = new PolylinePath();
Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
christian voigt

I have the same problem. Upgrading to 2023.3.0a18 did not help either.

Freya Holmér creator

looks like this might actually be a bug with the mesh disposal!

If you want a fix in the meantime - use persistent polylines instead (which are also much more performant)

using Shapes;
using UnityEngine;

[ExecuteAlways] public class DebugPolyline : ImmediateModeShapeDrawer {

PolylinePath path;

public override void OnEnable() {
base.OnEnable(); // <- very important
path = new PolylinePath(); // create once

public override void OnDisable() {
base.OnDisable(); // <- very important
path.Dispose(); // delete once

public override void DrawShapes( Camera cam ) {
using( Draw.Command( cam ) ) {
Draw.Matrix = transform.localToWorldMatrix;
path.AddPoint( Vector3.zero );
path.AddPoint( Vector3.up );
path.AddPoint( Vector3.right );
Draw.Polyline( path );

christian voigt

thanks for the fix!