How do I load a map in a commandlet? I need to iterate over all levels in the world, and all actors in each level to export them in our custom format.
The following approaches do not work… (with various tweaks)
UGameplayStatics::OpenLevel( GWorld, FName( "SunTemple" ), true );
GEngine->LoadMap( *GEngine->GetWorldContextFromWorld( GWorld ), URL, nullptr, Error );
GEngine->SetClientTravel( GWorld, TEXT( "?SunTemple" ), TRAVEL_Absolute );
UPackage* Package = LoadPackage( nullptr, TEXT( "/Game/Maps/SunTemple.umap" ), LOAD_EditorOnly );
GEditor->HandleMapCommand( TEXT( "LOAD FILE=" ), Ar, GWorld );
FEditorFileUtils::LoadMap( TEXT( "/Game/Maps/SunTemple.umap" ) );
Any tips would be greatly appreciated!
Cheers
John
K.Mostovyi
(K.Mostovyi)
2
Hello John,
I hope that the following links will be useful
You can specify UWorld class in AssetRegistry::GetAssetsByClass or UObjectLibrary::CreateLibrary function
Sincerely,
Kostiantyn
This worked - thanks! How do I mark as resolved?
Cheers
John
Mauxx91
(Mauxx91)
4
call this to load a world in the commandlet:
UWorld * world = FAssetUtilityLibrary::LoadLevel(environment.GetUnrealMapPath());
call this to create a new world in the commandlet
UWorld* NewWorld = UWorld::CreateWorld(EWorldType::None, false);