Unreal/CarlaUE4/Plugins/RoadRunnerCarlaIntegration/Source/RoadRunnerCarlaIntegration/Private/RoadRunnerCarlaIntegration.cpp
////////////////////////////////////////////////////////////////////////////////
// Since creating the map is done pre-import, a new map will be opened even if
// the import was cancelled
Since creating the map is done pre-import, a new map will be opened even if
the import was cancelled
Since creating the map is done pre - import a new map will be opened even if the import was cancelled
void FRoadRunnerCarlaIntegrationModule::RRCarlaPreImport(UFactory* inFactory, UClass* inClass, UObject* inParent, const FName& name, const TCHAR* type)
{
	if (!inFactory->IsA<URoadRunnerFbxSceneImportFactory>())
	{
		return;
	}
	URoadRunnerFbxSceneImportFactory* rrFactory = Cast<URoadRunnerFbxSceneImportFactory>(inFactory);
	if (!rrFactory->OuterCall)
	{
		return;
	}
	UE_LOG(RoadRunnerCarlaIntegration, Log, TEXT("Starting RoadRunner pre-import"));
	FString packageName;
	if (FPackageName::DoesPackageExist(BaseMapPath, nullptr, &packageName))
	{
		GEditor->CreateNewMapForEditing(); 
		if (!FEditorFileUtils::LoadMap(BaseMapPath, true, false))
			UE_LOG(RoadRunnerCarlaIntegration, Error, TEXT("BaseMap failed to load"));
		FString importFileName = FPaths::GetBaseFilename(name.ToString());
		FString mapName = FPaths::ProjectContentDir() + MapDestRelPath + importFileName + ".umap";
		FEditorFileUtils::SaveLevel(GWorld->PersistentLevel, mapName);
	}
	else
	{
		UE_LOG(RoadRunnerCarlaIntegration, Error, TEXT("BaseMap could not be found."));
	}
}
void FRoadRunnerCarlaIntegrationModule :: RRCarlaPreImport ( UFactory * inFactory , UClass * inClass , UObject * inParent , const FName & name , const TCHAR * type ) { if ( ! inFactory -> IsA < URoadRunnerFbxSceneImportFactory > ( ) ) { return ; } URoadRunnerFbxSceneImportFactory * rrFactory = Cast < URoadRunnerFbxSceneImportFactory > ( inFactory ) ; if ( ! rrFactory -> OuterCall ) { return ; } UE_LOG ( RoadRunnerCarlaIntegration , Log , TEXT ( " " ) ) ; FString packageName ; if ( FPackageName :: DoesPackageExist ( BaseMapPath , nullptr , & packageName ) ) { GEditor -> CreateNewMapForEditing ( ) ; if ( ! FEditorFileUtils :: LoadMap ( BaseMapPath , true , false ) ) UE_LOG ( RoadRunnerCarlaIntegration , Error , TEXT ( " " ) ) ; FString importFileName = FPaths :: GetBaseFilename ( name . ToString ( ) ) ; FString mapName = FPaths :: ProjectContentDir ( ) + MapDestRelPath + importFileName + " " ; FEditorFileUtils :: SaveLevel ( GWorld -> PersistentLevel , mapName ) ; } else { UE_LOG ( RoadRunnerCarlaIntegration , Error , TEXT ( " " ) ) ; } }
Since creating the map is done pre-import, a new map will be opened even if
the import was cancelled
Since creating the map is done pre - import a new map will be opened even if the import was cancelled
// Ensure this is only called from our delegate calls // Search for the base map // Note: Creates save pop-up for currently loaded level // Load base map as template // Automatically save map with correct name