How can I draw multiple lines in UMG

I’m trying to use the OnPaint override and Draw Line in a blueprint to draw a compass plot, with many lines coming from a single origin. The number of lines needed is not fixed. How can I do this?

  • I can’t loop through the Draw Line function because OnPaint reinitiates every tick and only the first line is drawn.
  • DrawLines draws a polyline of sequentially connected segments, rather than all segments radiating from a common origin

Thanks

Never mind - I just had the return node inside the loop. This works:

Unreal default “DrawLine” api has inconvenient points for developers:

  • Lines can not be previewed and edited in UMG editor.
  • Hard to edit complex lines.
  • Can not draw splines.
  • Can not set a brush for the line geometry.
  • Can not be used as a rail for other widgets.

Maybe you can try the “UMGSpline” plugin to solve your problems:
UMGSpline in Code Plugins - UE Marketplace

1 Like

Not really true:

But UMG is very limited with anything beyond the most basic. Awesome plugin.

@ilike9527 Is it safe to assume you repurposed the spline methods BPs are using for the wires?

Wow, thanks for letting me know that. I tried like your link and the lines can be previed in UMG editor. Sorry I have not tested the feature carefully.

Functions for spline rendering and editing is using slate original apis. Only functions for calculating spline rail location is similar as BPs, as they are all bezier splines, so they can be calculated the same way. And I have made some changes and limitions for 2D space, the functions work fine in my test.

1 Like