Solved importing for more that 1 package and avoid propmap creation if no props found

This commit is contained in:
Manish 2019-07-03 18:16:34 +02:00 committed by Néstor Subirón
parent a9eafaba25
commit b7c670f638
3 changed files with 27 additions and 20 deletions

View File

@ -88,6 +88,7 @@ TArray<AStaticMeshActor *> UCookAssetsCommandlet::AddMeshesToWorld(
}
AssetsObjectLibrary->AddToRoot();
AssetsObjectLibrary->ClearLoaded();
AssetsObjectLibrary->LoadAssetDataFromPaths(AssetsPathsDirectories);
AssetsObjectLibrary->LoadAssetsFromAssetData();
@ -133,7 +134,7 @@ TArray<AStaticMeshActor *> UCookAssetsCommandlet::AddMeshesToWorld(
return SpawnedMeshes;
}
void UCookAssetsCommandlet::DestroyWorldSpawnedActors(TArray<AStaticMeshActor *> &SpawnedActors)
void UCookAssetsCommandlet::DestroySpawnedActorsInWorld(TArray<AStaticMeshActor *> &SpawnedActors)
{
for (auto Actor : SpawnedActors)
{
@ -299,11 +300,13 @@ 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("+"));
}
if (AssetsPaths.PropsPaths.Num() > 0)
{
FString MapName("PropsMap");
FString WorldDestPath = TEXT("/Game/") + PackageParams.Name +
TEXT("/Maps/") + MapName;
@ -316,10 +319,14 @@ int32 UCookAssetsCommandlet::Main(const FString &Params)
SaveStringTextToFile(SaveDirectory, FileName, MapPathData, true);
// Add props in a single Base Map
AddMeshesToWorld(AssetsPaths.PropsPaths, false);
TArray<AStaticMeshActor *> SpawnedActors = AddMeshesToWorld(AssetsPaths.PropsPaths, false);
SaveWorld(AssetData, PackageParams.Name, WorldDestPath, MapName);
DestroySpawnedActorsInWorld(SpawnedActors);
MapObjectLibrary->ClearLoaded();
}
return 0;
}
#endif

View File

@ -92,7 +92,7 @@ public:
*/
bool SaveWorld(FAssetData &AssetData, FString &PackageName, FString &DestPath, FString &WorldName);
void DestroyWorldSpawnedActors(TArray<AStaticMeshActor *> &SpawnedActors);
void DestroySpawnedActorsInWorld(TArray<AStaticMeshActor *> &SpawnedActors);
/**
* Get Path of all the Assets contained in the package to cook

View File

@ -235,8 +235,8 @@ def import_assets_from_json_list(json_list):
move_uassets(package_name, maps)
if not package_name:
print("No Packages JSONs found, nothing to import. Exiting.")
exit(0)
print("No Packages JSONs found, nothing to import. Skipping package.")
continue
# Prepare cooking of package
prepare_cook_commandlet(package_name)