#include "RuntimeAssetCache/Public/RuntimeAssetCache.h"#include "AssetData.h"void GetAssetPropertyFromAnotherProject(){ FString ProjectName = TEXT("bbb"); // 资产所在的项目名称 FString AssetPath = TEXT("/Game/cc"); // 资产的路径 // 获取资产数据 TArray<FAssetData> AssetDataArray; FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry"); FARFilter Filter; Filter.PackagePaths.Add(FName(*FString::Printf(TEXT("/%s"), *ProjectName))); Filter.bRecursivePaths = true; Filter.ClassNames.Add(UObject::StaticClass()->GetFName()); Filter.PackageNames.Add(FName(*AssetPath)); AssetRegistryModule.Get().GetAssets(Filter, AssetDataArray); if (AssetDataArray.Num() > 0) { const FAssetData& AssetData = AssetDataArray[0]; // 获取资产路径 FString AssetPackagePath = FString::Printf(TEXT("%s.%s"), *AssetData.PackageName.ToString(), AssetData.ObjectPath.ToString()); // 加载资产 UObject Asset = FRuntimeAssetCache::Get().LoadAssetFromPath(AssetPackagePath, true); if (Asset) { FString AssetName = Asset->GetName(); // 获取资产属性 // ... } }} 这段代码需要引入什么build 文件
时间: 2024-02-17 17:04:20 浏览: 103
这段代码需要引入以下模块的.build.cs文件:
```
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "AssetRegistry", "RuntimeAssetCache" });
```
这个代码使用了Unreal Engine 4中的AssetRegistry模块和RuntimeAssetCache模块,需要在.build.cs文件中添加对它们的引用。同时,需要添加对Core、CoreUObject和Engine模块的引用,因为这些模块是Unreal Engine 4中的基础模块。
阅读全文