I’m trying to assemble a TArray<FName> containing the name of every map in my game. As a test, I added five streaming levels to the persistent level, appropriately named StreamTest0 through StreamTest4. I then queried UWorld::StreamingLevels to get a reference to them at runtime:
TArray<FName> AWorldManager::GetAllMapNames() {
TArray<FName> nameList;
TArray<ULevelStreaming*> tempLevels = GetWorld()->StreamingLevels; //Get a reference to every level configured to stream in
for (int i = 0; i < tempLevels.Num(); i++) { //Iterate through the list, and get the name of each level
nameList.Add(tempLevels*->GetFName());
}
return nameList;
}
This returns the correct number of names, but instead of “StreamTest0” my first map isnamed “LevelStreamingKismet_0,” and the remaining four are predictably named LevelStreamingKismet 1-4. I tried substituting GetWorldAssetPackageFName() for GetFName() with the hope that it’d return the asset’s name instead of the weird Kismet string, but in addition to the asset’s name the package name returned the complete filepath, as in “/Game/Maps/StreamTest0”. Is there a function I’m not seeing in ULevelStreaming | Unreal Engine Documentation or in intelisense that will return the map name, but will not add the entire file path first?