Afaik this is not simple because assets/packages are not always loaded at all times, and asset registry does not know about blueprints hierarchical inheritance.
However, asset registry has ability to search by tags, and blueprints do store their parent class path and their closest native parent class path into tags.
Unfortunately searching by tags is not exposed to blueprints so you’ll need C++ utility to get anything done on that front.
Here is an example utility that searches blueprints children of a given native parent class :
#include "AssetRegistry/AssetRegistryModule.h"
bool USomeUtility::FindBlueprintsChildOf(TSubclassOf<UObject> InNativeClass, TArray<FAssetData>& FoundAssets)
{
if (!InNativeClass || !InNativeClass->IsNative())
return false;
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
TMultiMap<FName, FString> TagsValues;
// All native CDOs should be in memory - we can look up native subclasses of InNativeClass
for (FThreadSafeObjectIterator It(InNativeClass); It; ++It)
{
UClass* Class = It->GetClass();
if (Class->IsNative() && Class->ClassDefaultObject == *It)
{
TagsValues.AddUnique(FBlueprintTags::NativeParentClassPath, FString::Printf(TEXT("%s'%s'"), *Class->GetClass()->GetName(), *Class->GetPathName()));
}
}
return AssetRegistryModule.Get().GetAssetsByTagValues(TagsValues, FoundAssets);
}
I am adding all native subclasses of the provided class, so if you supply “Pawn” it will effectively also look for “Character” subclasses and “SpectatorPawn” subclasses etc.
You can theoretically achieve something similar with a blueprint base class, using the FBlueprintTags::ParentClassPath
tag instead, however if you also need to fetch grandchildren you’ll probably have to implement some additional recursion.