Using Lyra's CommonGame Plugin in another project crashes when setting Layout Class in GameUIPolicy

Like the title describes i get this crashing when Selection Layout Class

Fatal error: [File:D:\build\++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 10] Cast of Package /Game/UI/B_RWUIPolicy to GameUIManagerSubsystem failed

UnrealEditor_CoreUObject
UnrealEditor_CommonGame!UGameUIPolicy::GetOwningUIManager() [E:\Game Dev\RisingWraith\Plugins\CommonGame\Source\Private\GameUIPolicy.cpp:33]
UnrealEditor_CommonGame!UGameUIPolicy::GetWorld() [E:\Game Dev\RisingWraith\Plugins\CommonGame\Source\Private\GameUIPolicy.cpp:38]

This is driving me insane!!! i have everything setup properly like it is in lyra yet still it crashes everytime…

I’ve been fighting this crash for more than 2 weeks now and I can’t find a solution!

1 Like

Did you ever find out why this is happening? I’m confident I’m in the same boat. I’m adding the overall ui width to the GameUIPolicy and it crashes because a cast to it’s outer fails.

Same problem…

Hey Spvnn, not sure why, but when we copied (Literally copying the uasset from windows explorer not migrating) the GameUIPolicy from the Lyra project, it worked without issue. Then we created a new one from scratch and it worked fine. Still have no idea why, but we moved passed it.

I create {ProjectName}UIManagerSubsystem (just copied LyraUIManagerSubsystem) , add it in DefaultEngine.ini → [/Script/Engine.Engine] GameUIManagerSubsystemClassName=/Script/.{ProjectName}UIManagerSubsystem, then it works well
in DefaultGame.ini, I add [/Script/.{ProjectName}UIManagerSubsystem]
DefaultUIPolicyClass=/Game/Blueprints/UI/{ProjectName}BP_UIPolicy.{ProjectName}BP_UIPolicy_C

I’ve found the reason. It’s a bug with GameUIPolicy.cpp.

For some reason if you’re currently loading an “open world” type of level in the editor (i.e. one where you can choose to use World Partition setup), GetWorld() is called on GameUIPolicy by a class related to World Partition (it’s called on many things, I didn’t bother figuring out why). Then this calls GetOwningUIManager which has a CastChecked<> in it that’s failing. Because GetOuter() at editor time is the BP_UIPolicy file.

You can verify that the cause of the issue is the level loaded by opening lyra, opening a level that has world streaming (e.g. any of the play levels like Convolution) and then try changing that exact same dropdown box in BP_UIPolicy and set the PrimaryLayout. The editor will also crash. It only doesn’t crash in Lyra when you set this dropdown in the initial level which isn’t an “Open World” level.

People are encountering this in their own projects because the default level in a third person template is also an open world level, which triggers this bug. To temporarily get around it you could try setting this dropdown in a new level that isn’t an open world level. Hopefully Epic gets around to fixing this…

3 Likes

To temporarily get around it you could try setting this dropdown in a new level that isn’t an open world level.

Confirmed this works! You need to create the new level and save it (I used a Blank level), close the editor down and relaunch it (make sure you load last viewed map by default). And then it will let you update the dropdown.

Thanks!!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.