Download

Is it possible draw HUD or just some simple lines in editor?

Is it possible draw UMG HUD or just some simple 2d lines in editor?
If it is, then what should I do?
Thanks!

Yes, you need to override the OnPaint() function and call DrawLines.

Bear in mind that lines will be drawn over the top of everything in that widget.

Thank you!
" …lines will be drawn over the top of everything in that widget."
That’s exactly what I needed!
Edit: found something useful here: https://wiki.unrealengine.com/Slate,_Hello

If you plan on drawing a LOT of lines, you may want to copy the content of the DrawLines function and tab out the ContentLayer++; entry, and draw all lines on the same layer.

I draw around 100-200 lines for my radar, and having each on a separate layer was killing my frame time.

Just to be sure. Is this suitable for auxiliary gui elements such are visible only in editor?
As an example, I want to add a wireframe box to a component, which can be moved and scaled. Somewhat similar to how physics constraints outline connected objects.

Shouldn’t be too much of a problem, just be aware that if you do start taking some hits to framerate, tabbing out that line would be the first place to start :slight_smile:

Another question:
I want to show my HUD in editor, but I don’t know how.
I’ve successfully show my HUD in PIE mode, but I want to HUD show in editor.
I’ve followed this tutorial, now I want to modify this to let
my HUD display in editor.
The biggest problem here is when I try to AddViewportWidgetContent in PostInitializeComponents(), only this
PostInitializeComponents won’t be called in editor.
Since AHUD is an AActor, I’ve tried override lots of functions like PostLoad, but they just don’t be called.
I tried AddViewportWidgetContent in constructor, but GEngine isn’t ready during construction and returing NULL.
So my question is, how to show my HUD in editor like THIS?
Thanks!