diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp index 6c182e321..f726dc137 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.cpp @@ -88,6 +88,7 @@ TArray UCookAssetsCommandlet::AddMeshesToWorld( } AssetsObjectLibrary->AddToRoot(); + AssetsObjectLibrary->ClearLoaded(); AssetsObjectLibrary->LoadAssetDataFromPaths(AssetsPathsDirectories); AssetsObjectLibrary->LoadAssetsFromAssetData(); @@ -133,7 +134,7 @@ TArray UCookAssetsCommandlet::AddMeshesToWorld( return SpawnedMeshes; } -void UCookAssetsCommandlet::DestroyWorldSpawnedActors(TArray &SpawnedActors) +void UCookAssetsCommandlet::DestroySpawnedActorsInWorld(TArray &SpawnedActors) { for (auto Actor : SpawnedActors) { @@ -299,26 +300,32 @@ int32 UCookAssetsCommandlet::Main(const FString &Params) SaveWorld(AssetData, PackageParams.Name, Map.Path, Map.Name); // Remove spawned actors from world to keep equal as BaseMap - DestroyWorldSpawnedActors(SpawnedActors); + DestroySpawnedActorsInWorld(SpawnedActors); MapPathData.Append(Map.Path + TEXT("/") + Map.Name + TEXT("+")); } - FString MapName("PropsMap"); - FString WorldDestPath = TEXT("/Game/") + PackageParams.Name + - TEXT("/Maps/") + MapName; + if (AssetsPaths.PropsPaths.Num() > 0) + { + FString MapName("PropsMap"); + FString WorldDestPath = TEXT("/Game/") + PackageParams.Name + + TEXT("/Maps/") + MapName; - MapPathData.Append(WorldDestPath + TEXT("/") + MapName); + MapPathData.Append(WorldDestPath + TEXT("/") + MapName); - // Save Map Path File for further use - FString SaveDirectory = FPaths::ProjectContentDir() + PackageParams.Name + TEXT("/Config"); - FString FileName = FString("MapPaths.txt"); - SaveStringTextToFile(SaveDirectory, FileName, MapPathData, true); + // Save Map Path File for further use + FString SaveDirectory = FPaths::ProjectContentDir() + PackageParams.Name + TEXT("/Config"); + FString FileName = FString("MapPaths.txt"); + SaveStringTextToFile(SaveDirectory, FileName, MapPathData, true); - // Add props in a single Base Map - AddMeshesToWorld(AssetsPaths.PropsPaths, false); + // Add props in a single Base Map + TArray SpawnedActors = AddMeshesToWorld(AssetsPaths.PropsPaths, false); - SaveWorld(AssetData, PackageParams.Name, WorldDestPath, MapName); + SaveWorld(AssetData, PackageParams.Name, WorldDestPath, MapName); + + DestroySpawnedActorsInWorld(SpawnedActors); + MapObjectLibrary->ClearLoaded(); + } return 0; } diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h index f34afbd31..2ee44447c 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Commandlet/CookAssetsCommandlet.h @@ -92,7 +92,7 @@ public: */ bool SaveWorld(FAssetData &AssetData, FString &PackageName, FString &DestPath, FString &WorldName); - void DestroyWorldSpawnedActors(TArray &SpawnedActors); + void DestroySpawnedActorsInWorld(TArray &SpawnedActors); /** * Get Path of all the Assets contained in the package to cook diff --git a/Util/BuildTools/Import.py b/Util/BuildTools/Import.py index 06b684455..172110173 100755 --- a/Util/BuildTools/Import.py +++ b/Util/BuildTools/Import.py @@ -234,13 +234,13 @@ def import_assets_from_json_list(json_list): import_assets(package_name, dirname, props, maps) move_uassets(package_name, maps) - if not package_name: - print("No Packages JSONs found, nothing to import. Exiting.") - exit(0) + if not package_name: + print("No Packages JSONs found, nothing to import. Skipping package.") + continue - # Prepare cooking of package - prepare_cook_commandlet(package_name) - print() # Fixes a ugly artifact after the commandlet output + # Prepare cooking of package + prepare_cook_commandlet(package_name) + print() # Fixes a ugly artifact after the commandlet output def move_uassets(package_name, maps):