Download

UE4 Editor doesn't start when getting BP class in C++ GameMode

I have a C++ class that derives from AGameMode, and a BP class that derives from that custom C++ game mode class. In the project I have set the BP game mode class as game mode to use. Everything works fine, except in one case.

When I call the following line in the constructor of the C++ class:


static ConstructorHelpers::FObjectFinder<UBlueprint> Blueprint(TEXT("Blueprint'...'"));
// "Blueprint'...'" is a valid path to an existing BP asset, ref. copied from editor

then compilation in Visual Studio 2015 works fine. However, after building the solution and restarting the UE4 editor, the UE4 startup splash screen shows up, but freezes at exactly 72% (every time). This happens also in a fresh project, can be reproduced every time. I am using official UE4.12.5.

This seems to be a bug. Or is it a feature?
How else is one supposed to get a UClass* reference to a BP class from within a C++ game mode class?

Well you could create a TSubclassOf variable for that class and expose it to Blueprints.
Then you can easily set the class variable in the Blueprint child of your GameMode class.

That’s true, would be the manual approach.
I am looking for an “automatic” solution based on just the BP reference path, without manual intervention though …