Rendering to specific camera, coding issue

Hello,

I’m trying to render a path with Aline to a specific cam.
I’m getting this error from my IDE :

could you help about it ? (code is below) Thanks !
void Update()
{
var buffer = new List();
ai.GetRemainingPath(buffer, out bool stale);

    for (int i = 0; i < buffer.Count - 1; i++)
    {

        using (var draw = DrawingManager.GetBuilder(true))
        {

         

            draw.cameraTargets = new[] {myCamera};

           
          
            
            using (Draw.ingame.WithColor(Color.red))
            {



                {
                    Draw.ingame.Line(buffer[i], buffer[i + 1]);
                }
            }
            draw.Dispose();
        }

    }
}

Hi

Yes, that’s a C# limitation. You have to do this instead:

var draw = DrawingManager.GetBuilder(true);
draw.cameraTargets = new[] {myCamera};

using (draw) {            
	using (draw.WithColor(Color.red)) {
		draw.Line(buffer[i], buffer[i + 1]);
	}
}

Note that I also changed your Draw.ingame to use your created command builder instead of the global one.

I’d also recommend that you use a single builder for all your buffers, instead of one per buffer (unless your buffers are really large).

You may also be interested in CommandBuilder.Polyline.

thanks a lot for your quick answer ! it works like a charm…

Great to hear! :slight_smile:

If you enjoy using the package, a rating and/or review on the asset store goes a long way towards supporting further development :slight_smile: