Efficient Way to Draw to RenderTarget?

I’m looking for a solution to drawing lines, boxes, and text to a render target accessible to an actor in an efficient manner. So far the best option seems to be overriding the NativePaint() function in a class deriving from UUserWidget, then assigning the UserWidget to a WidgetComponent within an actor, then getting the render target. I don’t like this, because it seems to have unnecessary steps (ie: I don’t need the widget rendered to the widget component, and I end up trying to hide it by scaling it down) and seems inefficient.

These drawing operations aren’t predictable, I can’t just set everything up in UMG with text boxes, borders, and textures. I need to be able to draw on a canvas based in an unpredictable manner but based on specific criteria (eg: draw a line from (x,y) to (x,y) with some thickness)

drawmaterialtorendertarget is what ur searching for.

if u are using a canvasrendertarget2d u can use begindrawcanvastorendertarget and then call drawline etc from a canvas. dont forget to call enddrawcanvastorendertarget.

it might be hard then ro use the rendertarget. a good method is to use the rendertarget as texturesample inside a material and then use the material

No need to scale down the widget component , you can set render in main pass for widget component to false so it will not render in the world and you can still have the component in level and use it however you like.