kriskirov
(kriskirov)
September 21, 2018, 1:13pm
1
Hello people,
I have found out that the UE 4.19.2 crashes when I have the following code inside the constructor of my UUserWidget derived class:
UUI_MainMenuParentWidget::UUI_MainMenuParentWidget(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer)
{
static ConstructorHelpers::FClassFinder<UUserWidget> BP_UIMainMenutWidgetClassFinder(TEXT("/Game/UI/BP_UIMainMenuWidget"));
if (BP_UIMainMenutWidgetClassFinder.Succeeded()) {
BP_UIMainMenuWidgetClass = BP_UIMainMenutWidgetClassFinder.Class;
}
}
This happens when I attempt to “CreateWidget” for the specified blueprint class. Is far as I researched this should work everywhere in the engine constructors as mentioned here (or at least no exceptions have been mentioned). The same code works perfectly fine in the game mode. Is it me missing something, or is it a bug?
Jambax
(Jambax)
September 21, 2018, 5:26pm
2
Post the crash and/or log, can’t really help you unless we know why it’s crashing.
Obviously, you can’t call ‘CreateWidget’ in a constructor - assuming you meant you’re trying to call that somewhere else?
Zeblote
(Zeblote)
September 21, 2018, 6:58pm
3
The path to a clueprint class would be
/Game/UI/BP_UIMainMenuWidget.BP_UIMainMenuWidget_C
kriskirov
(kriskirov)
September 26, 2018, 10:32am
4
Ok, this was a mistake on my end. I had commented the content of my Initialize() override method and thus the Super::Initialize() was missing as well. This caused all the fuzz. This dodgy Super
Talad
(Talad)
May 20, 2020, 11:42pm
5
This is how it worked for me:
In the .h file:
UPROPERTY(BlueprintReadWrite, VisibleAnywhere, Category = “PlaneShift”)
class UWidgetComponent* ItemNameText;
In the .cpp file:
ItemNameText = CreateDefaultSubobject<UWidgetComponent>(FName(“ItemNameText”));
static ConstructorHelpers::FClassFinder<UUserWidget> nameTextWidget(TEXT(“WidgetBlueprint’/Game/UI/game/win/win_NameText.win_NameText_C’”));
ItemNameText->SetWidgetClass(nameTextWidget.Class);
ItemNameText->SetWidgetSpace(EWidgetSpace::Screen);
ItemNameText->SetupAttachment(this->GetRootComponent());