The following Unreal Gotcha burned us on our current project, so just in case someone else hits this I’m putting the situation up here. We were doing a Halloween version of our Impossible Travel Agency VR project, and we made a second set of maps that all had the HAL_ prefix on them. Then, based on which button you hit in the menu, it would stream load the appropriate set of maps for the normal or Halloween version of the game. This worked great in the editor, but failed in the packaged build. You always got the Halloween version of the maps, even though you hit the normal button. We tracked this into the load level node, which even when given the normal name was loading the wrong file. This is the culprit:
ULevelStreaming* FStreamLevelAction::FindAndCacheLevelStreamingObject( const FName LevelName, UWorld* InWorld )
{
// Search for the level object by name.
if( LevelName != NAME_None )
{
const FString SearchPackageName = MakeSafeLevelName( LevelName, InWorld );
for (ULevelStreaming* LevelStreaming : InWorld->StreamingLevels)
{
// We check only suffix of package name, to handle situations when packages were saved for play into a temporary folder
// Like Saved/Autosaves/PackageName
if (LevelStreaming &&
LevelStreaming->GetWorldAssetPackageName().EndsWith(SearchPackageName, ESearchCase::IgnoreCase))
{
return LevelStreaming;
}
}
}
return NULL;
}
It will return the first level it finds that ends with the string you passed it. So if your level names differ only by a prefix it will return the wrong one for one map or the other, depending on the order they’re in the list. It’s apparently intentional, since they’re trying to handle the directory portion being different in temp folders, but they probably should have stripped the path before doing the test instead of just checking “EndsWith.”
Hopefully this will save someone else some pain.
Rick