In Unreal Engine blueprint widget, you can create different shapes through an array of points. There is no line drawing in the user widget with an array of points in C++, so we will use UWidgetBlueprintLibrary. In order to draw the shape, we must use UWidgetBlueprintLibrary::DrawLines. And then another trouble awaits us — we cann’t override OnPaint.
All animals are equal, but some animals are more equal than others.
So, we’ll just override NativePaint.
int32 UPaintWidget::NativePaint(const FPaintArgs &Args,
const FGeometry &AllottedGeometry, const FSlateRect &MyCullingRect, FSlateWindowElementList &OutDrawElements, int32 LayerId, const FWidgetStyle &InWidgetStyle, bool bParentEnabled) const
{
Super::NativePaint(Args, AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); FPaintContext Context(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); UWidgetBlueprintLibrary::DrawLines(Context, Points, FLinearColor::Blue, true, 10.0f); return LayerId + 1;
}
We simply created a variable of the array of points in the class and by updating this array, our shape is also updated.
The complete code of this project is available on GitHub.
https://medium.com/@qerrant/gesture-recognizer-for-unreal-engine-24422d5868ba
반응형
'게임엔진(GameEngine) > Unreal4' 카테고리의 다른 글
애니메이션 디스턴스매칭 (0) | 2023.02.20 |
---|---|
TSharedPtr<.... , ESPMode::ThreadSafe> 스레드 안정성 (0) | 2023.01.20 |
JNI Data Type Mapping to C/C++ (0) | 2022.10.07 |
Android 에서 Java -> 호출 (0) | 2022.10.06 |
UE4 RPC - Replicate (0) | 2022.09.15 |