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?

Hey -

Is the blueprint being referenced by your Constructor Helpers the BP based on the GameMode class? If so then this would be expected as the parent class can’t reference a ChildBP. In a way, the constructor helper would be looking for itself. You can use the same code to retrieve a reference to your game mode blueprint from another class, or use it to get a reference to a blueprint with a different parent.

Cheers

No, I am trying to get the refernce to a BP class that is derived from Actor, it has nothing to do with the C++ or BP game mode classes. Thus, I am not trying to get a reference to a BP game mode, but from the C++ game mode to a BP Actor.

Also, I don’t want or even can’t get this reference from another class. Why would I? There is a C++ game mode class and I want to get a BP Actor’s UClass reference from within the C++ game mode, either in its constructor or BeginPlay method or similar.

In that case can you provide the full code you’re using? I tried creating a GameMode class, a blueprint based on that class, and a blueprint based on Actor. When I use the ConstructorHelpers line that you posted originally to get a reference to my Actor blueprint, the editor was able to open without error. If you are able to reproduce this, can you post the exact steps you’re using to do so?

Well, that is very interesting. I have tried it with both, a fresh C++ and a new BP project, and in both cases it works fine, no freezes at editor startup. That is good and bad news …

Good, because I know my issue can be fixed somehow. Bad, because I have no idea where to look for this error. Is there any way to debug that UE4 editor startup process, any logs or so? Or is there another way to get a BP’s UClass reference from a C++ game mode class? I want to spawn that BP later from the game mode class.

UPDATE: Ok, I just found out that it is not the call to FObjectFinder that causes the problem, but the BP asset I am trying to get the reference to. When I create a new (therefore empty) BP class derived from Character, then I can retrieve the UClass reference to that new BP class fine.

Hmm… The original BP character itself, which causes the trouble, works fine within the game. So my question is still the same: Can I somehow debug that UE4 editor startup process, so that I can find out what exactly causes the problem?

You can try to check the logs to see where the startup process hangs. It sounds like the issue is with the blueprint itself. Can you try making a duplicate/copy of the blueprint and attempt to find its reference. If that still causes the project to fail to open, you may need to recreate the blueprint entirely.

Which logs do you mean, where is the startup process being logged?

The log files are in the project directory’s Saved/Logs folder. Each time the project is opened a new log file is created. If your project is getting stuck while opening, the log may show what was initialized last and may give a clue to where it is getting stuck.