Download

How to get Asset from Asset registry for C++ Actors?

Hello,

I have a StaticMeshActor in C++ project. I can copy its reference from “Content Browser” it’s copied as: “/Script//[ProjectName].[ActorName]”

But I can’t get it’s asset (FAssetData) from AssetRegistry in C++.

AssetRegistry finds no asset under “/Script” (even without any filters)


FARFilter Filter;
Filter.ClassNames.Add(AStaticMeshActor::StaticClass()->GetFName());
Filter.bRecursiveClasses = true;
Filter.PackagePaths.Add("/Script");
Filter.bRecursivePaths = true;

TArray<FAssetData> Assets;
AssetRegistry.GetAssets(Filter, Assets);

How to get FAssetData reference for a C++ Actor?

Thank you,

DS

Documentation says to do it like this (you might need “/Game/Script” in your case, id see if you can pick up a simple mesh as a test):


FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TArray<FAssetData> AssetData;
FARFilter Filter;
Filter.Classes.Add(UStaticMesh::StaticClass());
Filter.PackagePaths.Add("/Game/Meshes");
AssetRegistryModule.Get().GetAssets(Filter, AssetData);