Trying to get Blueprint asset using AssetRegistryModule

Hi!

I am trying to get class reference in my code using the AssetRegistryModule.

This is what i tried:

FARFilter Filter2;
Filter2.ClassNames.Add(UBlueprint::StaticClass()->GetFName());
Filter2.bRecursiveClasses = true;
Filter2.PackagePaths.Add("/Game/Blueprints");

TArray<FAssetData> AssetList;
AssetRegistryModule.Get().GetAssets(Filter2, AssetList);
TArray<UObject*> Subclasses;
// Iterate over retrieved blueprint assets
for (FAssetData asset : AssetList)
{
	// Get the the class this blueprint generates (this is stored as a full path)
	if (auto GeneratedClassPathPtr = asset.TagsAndValues.Find(TEXT("GeneratedClass")))
	{
		const FString ClassObjectPath = FPackageName::ExportTextPathToObjectPath(*GeneratedClassPathPtr);
		const FString ClassName = FPackageName::ObjectPathToObjectName(ClassObjectPath);
		UE_LOG(LogTemp, Warning, TEXT("%s"), *ClassObjectPath);			
		FoundClass = FStringClassReference(ClassObjectPath).TryLoadClass<AC_EmptyActor>();
		if (FoundClass)
			UE_LOG(LogTemp, Warning, TEXT("Conversion Success!"));


		
		if (FoundClass)
		{
			UE_LOG(LogTemp, Warning, TEXT("Trying to spawn!"));
			GetWorld()->SpawnActor<AActor>(FoundClass, FVector(0, 0, 0), FRotator(0, 0, 0));
			
		}

If i try code above, the game will crash. If i try to add location manually doing little change:
FoundClass = FStringClassReference("/Game/Blueprints/BP_EmptyActor.BP_EmptyActor").TryLoadClass();

Game won’t crash, but the FoundClass will be empty. I checked and the FString ClassObjectPath will return the full path for the class, so finding the class isn’t the problem here… I just don’t know how to get reference to the class, if i for example want to use it to spawn something. Any ideas what is wrong?

Foundclass is a TSubclassOf

Hey sorry for the delay, I solved this today, and I will left this if someone else need it:
Once you have your TArray AssetData; filled with the UBluprint found on your project you can create or do something else like this:

UBlueprint* blueprinto = Cast<UBlueprint>(AssetData[0].GetAsset());
	if ((blueprinto) )
	{

			for (TFieldIterator<UProperty> PropIt(blueprinto->GeneratedClass); PropIt; ++PropIt)
			{
				UProperty* Property = *PropIt;
				// Do something with the property
				UE_LOG(LogTemp, Warning, TEXT("%s"), *Property->GetName())
			}
	}

in this case just as demo, I hard coded this to the first element inside the array, cast to UBlueprint and you can access the generated class from there, in my case I simply iterate all UProperties, but you can spawn your stuff, you dont need to use FStringClassReference since you already have all this info anyway in the AssetData