GetAssetsByClass Node not working in 5.1 ?

Hi everyone,

I’m currently working on migrating one of my projects from 5.0 to 5.1 and I’m stuck with blueprint node GetAssetsByClass (from asset registry)

In previous versions, I was using it by providing the class name. This input no longer exists and I have to provide ClassPathName which is ‘TopLevelAssetPath’ structure.

I’ve created one and filled the Package name field with a path such as ‘/Game/Path/to/my/class’ and Asset name field with the name of the class. I’ve tried various combinations : MyClassName only, MyClassName_C (with was what I used with previous versions), MyClassName.MyClassName (from the copy reference item in the content browser). No luck so far, the node always returns an empty list.

I’ve also noticed in the debugger that there’s an additional dot before the className in the ClasspathName input of the node.

Could this be a bug with this node or am I doing something wrong with the package/class name here ?

Any help is appreciated.

Below is a caps of the former node vs the new node :

1 Like

Not sure how to interact with the new blueprint node in 5.1, but you can call it properly in C++ pretty easily.

TArray<FAssetData> AssetDataList;
	TArray<AActor*> ActorAssets; 
	IAssetRegistry& AssetRegistry = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")).Get();
	AssetRegistry.GetAssetsByClass(FTopLevelAssetPath(AActor::StaticClass()->GetPathName()), AssetDataList, true);

The change is that you now have to wrap the path of the class in an FTopLevelAssetPath struct.

3 Likes

How to use the new blueprint node:

Copy class reference
image

/Script/CoreUObject.Class’/Script/HeadGame.HGRiggedHair’

The bold part is Package Name

2 Likes

You can also get the class path doing this:

This way you could create your own wrapper function which just needs a class reference

6 Likes

Sorry I didn’t see your answer before.
Thank you very much for your help, this is very much appreciated. I’ll give this a try.

1 Like

Thanks a lot, google search didn’t find it

1 Like

hey , i used this and it works in editor but i want such behaviour at runtime , just to call it once and make a list of missions so i can showcase them in ui, i dont want to keep adding manually to the missions array:
TArray FoundMissions;
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked(“AssetRegistry”);
FTopLevelAssetPath BaseClassName = UMissionObject::StaticClass()->GetDefaultObject()->GetClass()->GetClassPathName();

	TArray<FName>Tags;
	Tags.Add("MissionObject");
	AssetRegistryModule.Get().GetAssetsByTags(Tags, FoundMissions);

	FullGameMissionsCount = FoundMissions.Num();

if (FullGameMissionsCount)
{
//lsome logics here
}
else
{
LOG_AMS(“Asset Registry No Assets Found”, 10.0f, FColor::Red);
}

any advice ?

Excuse me, has anyone solved this problem? I’ve tried a lot of things in Unreal Engine 5 blueprints to no effect, and for some reason I can’t use C++