I’ve been trying to figure this one out for several weeks. I need a way to draw lines & rects onto a custom slate widget, in order to visualize some internal data. And although I can’t seem to figure out where, I believe that somewhere, UE4 is doing this internally for things like SGraphEditor
.
So is there any way to actually draw lines in an SWindow
, or any other slate widget?
Where in code I should be looking?
Ok, so I was under the impression that you couldn’t actually override OnPaint
in 4.17+, but I guess that’s not the case after all. The solution to anyone trying to do so and getting compiler errors is to NOT copy/paste function definitions from the API docs, but instead, copy them from the engine source whenever possible.
In this particular case, the SCanvas::OnPaint
definition from the docs is actually missing it’s const
qualifier at the end, forcing the compiler to throw C3668.
The actual definition in code is:
virtual int32 OnPaint( const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled ) const override;
After fixing my custom widget class’s definition to match this, I got it to compile and was able to use the typical FSlateDrawElement::*
methods to paint onto the canvas.