Is there a good way to enumerate the umap files in a directory under /Game/?/ ?
I’d like to make a menu that lists all the umaps available under a folder for loading with tokenised text labels so that I don’t have to update the menu whenever the maps change.
Thanks!
I found an old solution and modified it a bit:
TArray<FString> UMenuUtilitiesLibrary::GetAllMapNamesInDirectory(FString directory) {
auto ObjectLibrary = UObjectLibrary::CreateLibrary(UWorld::StaticClass(), false, true);
ObjectLibrary->LoadAssetDataFromPath(directory);
TArray<FAssetData> AssetDatas;
ObjectLibrary->GetAssetDataList(AssetDatas);
TArray<FString> Names = TArray<FString>();
for (int32 i = 0; i < AssetDatas.Num(); ++i)
{
FAssetData& AssetData = AssetDatas[i];
auto name = AssetData.AssetName.ToString();
Names.Add(name);
}
return Names;
}
Original code: List all maps in project or directory - Programming & Scripting - Unreal Engine Forums
I will update this answer with the Blueprints to generate the buttons shortly.