The only problem I have is retrieving the Blueprint Widget class using C++. I can’t seem to get it.
header:
TSubclassOf<class UUserWidget> GUI_PlayerEye_Class;
UUserWidget* GUI_PlayerEye;
cpp:
// in PostInitializeComponents
static ConstructorHelpers::FClassFinder <UBlueprint> playerEyeGUI(TEXT("/Game/UI/BP_PlayerEye_GUI")); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ERROR HERE
GUI_PlayerEye_Class = (UClass*)playerEyeGUI.Class;
if (GUI_PlayerEye_Class == nullptr) { LOG_ERROR_SAFELY("GUI_PlayerEye_Class is NULL.") }
// in BeginPlay
GUI_PlayerEye = CreateWidget<UUserWidget>(this, GUI_PlayerEye_Class);
if (AddToViewport) { GUI_PlayerEye->AddToViewport(); }
It compiles but when running the game: Error in ConstructorHelpers.h on line 157: UE4Editor.exe has triggered a breakpoint.
I tried this instead but it generated more or less the same error:
static ConstructorHelpers::FObjectFinder<UBlueprint> playerEyeGUIObj(TEXT("/Game/UI/BP_PlayerEye_GUI")); // <<<<<<<<< ERROR HERE
if (playerEyeGUIObj.Succeeded())
{
GUI_PlayerEye_Class = (UClass*)playerEyeGUIObj.Object->GeneratedClass;
}