Help creating an array of Blueprint Actors and Materials from a folder

I have a folder filled with blueprint actors that are all children of a single parent blueprint actor. I have the goal of creating a custom blueprint node that would return an array of all these actor’s classes that I could use to iterate through to spawn those actors.

I read some useful questions here from people trying to accomplish similar things but have been unable to make it work.

The function (below) seems to hit on each one of the blueprint actors in the folder but returns “BlueprintGeneratedClass” for each of them. I tried casting that back to the base class but that didn’t work.

I also hope to create a similar function to return an array of all the Materials in a specific folder, but that function doesn’t work at all. It just returns nothing.

Even after reading through the documentation, I only half understand what’s going on which makes it hard to troubleshoot.

Any idea how I could make this work? Or perhaps there’s a better way to go about doing it?

Functions below:

TArray< UClass * > USharedDungeonBPNodes::GetBlueprintsInFolder(UClass* BaseClass, const FString& FolderPath) {
	TArray< UClass * > BlueprintClasses;

	UObjectLibrary* ObjectLibrary;
	ObjectLibrary = UObjectLibrary::CreateLibrary(BaseClass, true, true);
	ObjectLibrary->LoadBlueprintsFromPath(FolderPath);
	TArray<UBlueprintGeneratedClass *> ClassesArray;
	ObjectLibrary->GetObjects<UBlueprintGeneratedClass>(ClassesArray);

	for (int32 i = 0; i < ClassesArray.Num(); ++i)
	{
		UBlueprintGeneratedClass * BlueprintClass = ClassesArray[i];
		BlueprintClasses.Add(BlueprintClass->GetClass());
	}

	return BlueprintClasses;
}



TArray< UMaterial * > USharedDungeonBPNodes::GetMaterialsInFolder(const FString& FolderPath) {
	TArray< UMaterial * > Materials;

	UObjectLibrary* ObjectLibrary;
	ObjectLibrary = UObjectLibrary::CreateLibrary(UMaterial::StaticClass(), true, true);
	ObjectLibrary->LoadAssetsFromPath(FolderPath);
	ObjectLibrary->GetObjects<UMaterial>(Materials);

	return Materials;
}

Anyone at all?

Solution here for anyone interested: