I have a UMG widget class inheriting from UUserWidget
. In this widget, I am drawing some elements by overriding the NativePaint
function (also known as OnPaint
in Blueprint).
The drawing code is something very standard like this (simplified for readability):
int32 UMyWidget::NativePaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const
{
// Draw some curves on the AllotedGeometry
for (/* some loop */) FSlateDrawElement::MakeSpline(OutDrawElements, LayerId, AllottedGeometry.ToPaintGeometry(), /* the rest doesn't matter */ );
++LayerId
return Super::NativePaint(/* same args */);
}
This works fine, and the draw elements show up. The problem is, they are always drawn on top of widgets I add to this widget in UMG (so, all UMG widgets are are behind all DrawElements).
I assume something like the Z-Order, or the LayerID variable, could be responsible for this? Or is the graphics pipeline hard-coded to draw UMG first, and the OnPaint stuff second?
Is it possible to order these Draw Elements behind the rest of the UMG elements?