Iterate all Blueprints derived from a class

Is there a way to iterate all Blueprints that are derived from a certain class?

For instance, I have a base Weapon class, and I want to find all Blueprints derived this class to do something like populate a UI. Is this possible?

Cheers!

I’d love to know/have this as well. it’s important to me because of reasons :slight_smile:

Hi Matt -

Currently, you have to generate a list of actors by either using spatial queries (overlapping actors, etc), or by having those classes register themselves somewhere, like with a player or the game info manually.

We have plans to create a “Get All Actors of Class” node, which would return an array of actors of the specified class, and then let you iterate over those and call functions in a loop, but I’m afraid we haven’t gotten there yet. Once that’s in, it should do exactly what you’re describing. Until then, i’m afraid you’ll have to use one of the two methods above to get that functionality.

Hey Nick,

Thanks for that, thats what I suspected. I just had some thoughts about things like… in an RPG you could have a UI find a list of all Blueprints derived from a Skill class to populate a Skill Tree, for instance, rather than having to keep a list of the Blueprint references everywhere.
I really do hope there is something like this coming in the long run - it seems like it could help reduce dependencies on programmers and maintenance.

Yup, that sort of thing should be no problem. After we finish up all the system work, we’ll work on banging out a lot of these nodes to make the workflow for making games much tighter.

This can be achieved through a blueprint interface. In the BI you make bare bones functions, you simply tell it what the input and output variables are. Then in the Blueprint you are working on go to the blueprint properties and under ‘Interfaces’, go to ‘Implemented Interfaces’, click add and select you BI you made. The way this works is any time the function you made is called in one blueprint will also be called in all other blueprints. You can make so it is only called in that blueprint by itself, but that will still be called if another blueprint uses the function.

The way you implement it is to right click in your graph and add the function under ‘Interface Messages’. If you add it under ‘Call Function’ it will be the local version. From there you can either double click it on the graph or in the my blueprint section and put your implementation of the function in.

So for example you could have a witch cast a spell, and in the spell blueprint you call a function from a BI called SpellCastA, which could do something or remain empty, then have a flame blueprint that when it receives the message SpellCastA has been called the flames flair up.

You can find more information here: Blueprint Interface

Best Regards,

Ryan

maybe it’s just me not getting the question or the answer right, but I cannot see how interfacing a function across different BP classes can help collect a list of available (but not spawned or in-game) BP UAssets, if that’s even what the OP meant.

Hi,
I hope this can help you (tested with UE 4.3):
You can get all blueprint assets from specific location and check there parentclass.
in this case i get all Assets from “/Game/Blueprints/RoomModel” and check for "ARoomConnection"s.

FAssetRegistryModule* AssetRegistryModule = &FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));

TArray<FAssetData> AssetData;
FARFilter Filter;
Filter.ClassNames.Add( UBlueprint::StaticClass()->GetFName() ); //get blueprints
Filter.PackagePaths.Add("/Game/Blueprints/RoomModel"); //from location
AssetRegistryModule->Get().GetAssets(Filter, AssetData);
//AssetRegistryModule->Get().GetAssetsByClass(Class->GetFName(), AssetData);

for (TArray<FAssetData>::TConstIterator PkgIter = AssetData.CreateConstIterator(); PkgIter; ++PkgIter)
{
	FAssetData Asset = *PkgIter;
	UBlueprint* BlueAsset = Cast<UBlueprint>(Asset.GetAsset());
	if (BlueAsset->ParentClass == ARoomConnection::StaticClass()){
		GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, Asset.AssetName.GetPlainNameString());
	}
}

Hi Bellian,

This is an Archive post from the Unreal Engine 4 Beta that is no longer tracked. Some, if not all, the information in here is outdated and/or no longer relevant with the latest release.

Thank you!

Tim