这里需要build.cs中添加AssetRegistry 已经对应的头文件
bool UMyBlueprintFunctionLibrary::GetMapFullName(const FString& MapName, FString& FullMapName)
{
IAssetRegistry& AssetRegistry = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>("AssetRegistry").Get();
bool result = false;
if (!AssetRegistry.IsLoadingAssets())
{
TArray<FAssetData> MapList;
if (AssetRegistry.GetAssetsByClass(UWorld::StaticClass()->GetFName(), /*out*/ MapList))
{
FName TargetTestName(*MapName);
for (const FAssetData& MapAsset : MapList)
{
if (MapAsset.AssetName == TargetTestName)
{
FullMapName = MapAsset.PackageName.ToString();
result = true;
break;
}
}
}
}
return result;
}