I’m using UE5 and Visual Studio 2022. I ran into problems in a project and created a new project and migrated the code over. I had no problems in the old project with this so I’m not sure what is going on as NativeConstruct()
is the C++ version of EventConstruct
in Blueprints. I have a parent widget with this in the header.
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
class UButton* PlayButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* SettingsButton;
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton* QuitButton;
In the child BP I have this to satisfy the requirement of having the above buttons in the design.
And then in EventConstruct()
.
void UMainMenuWidget::NativeConstruct()
{
Super::NativeConstruct();
if (PlayButton)
{
PlayButton->OnClicked.AddDynamic(this, &UMainMenuWidget::OnPlayClicked);
PlayButton->SetIsEnabled(false);
}
else
{
UE_LOG(LogMainMenuWidget, Error, TEXT("NativeConstruct: PlayButton not initialized"))
}
if (SettingsButton)
{
SettingsButton->OnClicked.AddDynamic(this, &UMainMenuWidget::OnSettingsClicked);
SettingsButton->SetIsEnabled(false);
}
else
{
UE_LOG(LogMainMenuWidget, Error, TEXT("NativeConstruct: SettingsButton not initialized"))
}
if (QuitButton)
{
QuitButton->OnClicked.AddDynamic(this, &UMainMenuWidget::OnQuitClicked);
QuitButton->SetIsEnabled(false);
}
else
{
UE_LOG(LogMainMenuWidget, Error, TEXT("NativeConstruct: QuitButton not initialized"))
}
}
All 3 log stating they are null. I have the button imported #include "Components/Button.h"
. Why are these null now when they never were before? I have tried deleting Binaries, Saved, Intermediate, DerivedDataCache and the sln file and regenerated it all without success.