18 #if WITH_EDITORONLY_DATA 22 TArray<FString> Tokens;
23 TArray<FString> Params;
25 ParseCommandLine(*InParams, Tokens, Params);
29 FParse::Value(*InParams, TEXT(
"PackageName="), PackageParams.
Name);
33 FParse::Value(*InParams, TEXT(
"Maps="), Maps);
35 TArray<FString> MapNames;
36 Maps.ParseIntoArray(MapNames, TEXT(
" "),
true);
46 AssetsObjectLibrary = UObjectLibrary::CreateLibrary(UStaticMesh::StaticClass(),
false, GIsEditor);
51 for (
const auto &Map : PackageParams.
MapNames)
53 MoveAssetsFromMapForSemanticSegmentation(PackageParams.
Name, Map);
57 void MoveFiles(
const TArray<UObject *> &Assets,
const FString &DestPath)
59 check(DestPath.Len() > 0);
61 FAssetToolsModule &AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>(
"AssetTools");
62 TArray<FAssetRenameData> AssetsAndNames;
63 for (
auto AssetIt = Assets.CreateConstIterator(); AssetIt; ++AssetIt)
71 AssetsAndNames.Emplace(Asset, DestPath, Asset->GetName());
74 if (AssetsAndNames.Num() > 0)
76 AssetToolsModule.Get().RenameAssets(AssetsAndNames);
80 void UMoveAssetsCommandlet::MoveAssetsFromMapForSemanticSegmentation(
81 const FString &PackageName,
82 const FString &MapName)
85 const FString SrcPath = TEXT(
"/Game/") + PackageName + TEXT(
"/Maps/") + MapName;
94 TArray<FString> DestinationPaths = {SSTags::ROAD, SSTags::ROADLINE, SSTags::TERRAIN, SSTags::GRASS, SSTags::SIDEWALK, SSTags::CURB, SSTags::GUTTER};
97 TMap<FString, TArray<UObject *>> AssetDataMap;
98 for (
const auto &Paths : DestinationPaths)
100 AssetDataMap.Add(Paths, {});
107 UStaticMesh *MeshAsset = CastChecked<UStaticMesh>(MapAsset.GetAsset());
108 MapAsset.AssetName.ToString(AssetName);
113 const FString CurrentPackageName = MeshAsset->GetOutermost()->GetName();
115 if (!ensure(CurrentPackageName.StartsWith(SrcPath)))
122 if (AssetName.Contains(SSTags::R_ROAD1) || AssetName.Contains(SSTags::R_ROAD2))
124 AssetDataMap[SSTags::ROAD].Add(MeshAsset);
126 else if (AssetName.Contains(SSTags::R_MARKING1) || AssetName.Contains(SSTags::R_MARKING2))
128 AssetDataMap[SSTags::ROADLINE].Add(MeshAsset);
130 else if (AssetName.Contains(SSTags::R_TERRAIN))
132 AssetDataMap[SSTags::TERRAIN].Add(MeshAsset);
134 else if (AssetName.Contains(SSTags::R_SIDEWALK1) || AssetName.Contains(SSTags::R_SIDEWALK2))
136 AssetDataMap[SSTags::SIDEWALK].Add(MeshAsset);
138 else if (AssetName.Contains(SSTags::R_CURB1) || AssetName.Contains(SSTags::R_CURB2))
140 AssetDataMap[SSTags::CURB].Add(MeshAsset);
142 else if (AssetName.Contains(SSTags::R_GUTTER1) || AssetName.Contains(SSTags::R_GUTTER2))
144 AssetDataMap[SSTags::GUTTER].Add(MeshAsset);
148 AssetDataMap[SSTags::TERRAIN].Add(MeshAsset);
154 for (
const auto &Elem : AssetDataMap)
156 FString DestPath = TEXT(
"/Game/") + PackageName + TEXT(
"/Static/") + Elem.Key +
"/" + MapName;
158 MoveFiles(Elem.Value, DestPath);
162 int32 UMoveAssetsCommandlet::Main(
const FString &Params)
166 MoveAssets(PackageParams);
TArray< FString > MapNames
UMoveAssetsCommandlet()
Default constructor.
Struct containing Package Params, used for storing the parsed arguments when invoking this commandlet...
UObjectLibrary * AssetsObjectLibrary
Used for loading assets in object library.
TArray< FAssetData > MapContents
Loaded maps from any object library.