I’m trying to change my widget through code, but for some reason it keeps showing the old widget.
.h
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
UWidgetComponent* Widget;
.cpp
constructor:
Widget = CreateDefaultSubobject<UWidgetComponent>(TEXT("Widget"));
code:
Widget->SetWidgetClass(GameModeReference->Room1Widget);
When I run the program the widget gets changed in the editor but it keeps showing the old widget? I can’t figure out why
I’v tried using the follwing code but none of them seem to work:
Widget->SetVisibility(true);
Widget->RegisterComponent();
Widget->RequestRedraw();
Widget->UpdateWidget();