How can I determine how my custom UMG widget draws inside the editor?

Hey Team,

I am creating a custom UMG widget that extends UUserWidget. It uses functions like UWidgetBlueprintLibrary::DrawLine and FSlateDrawElement::MakeText to draw custom content but renders with UUserWidget::NativePaint(FPaintContext& context).

This render call only appears to occur during run-time and not in the UMG blueprint editor. Where must I place my draw code for it to render in-editor?

Cheers,
Mugen

Solution:

Each widget uses a slate widget to complete its drawing. An example of this can be seen in Image.h, where the image UWidget uses an SImage to draw its contents. All parameters are passed from the UWidget to the slate widget when the RebuildWidget() in the Image.h is called from the editor. This seems to either occur on load or on change of some widget parameters. The slate widget then calls draw functions for text, images etc.

Rendering code should be placed in the slate widget’s OnPaint function.