Using ForEachSelectedActor blutility function?!

Does anyone know how to use the “ForEachSelectedActor” and “ForEachSelectedAsset” functions available in Blutilities? They don’t have any output pins, they just call “OnEachSelectedActor” and “OnEachSelectedAsset” functions. Can someone show an example or explain how they work?


bump… :slight_smile:

It’s pretty straight forward. If you call “ForEachSelectedActor”, it will gather all Actors that you selected in your Editor Level (at least that’s the only “Selected Actors” I know),
and then iterates over them and calls “OnEachSelectedActor” for each of the Actors you’ve selected. Sounds a bit weird, but it’s simply a for each loop that gives you all Actors, one by one,
that you selected in the Level. Same probably happens for the Asset version.

Here is the C++ code of that function:

void UGlobalEditorUtilityBase::ForEachSelectedActor()
	TArray<AActor*> SelectionSetCache;
	for (FSelectionIterator It(GEditor->GetSelectedActorIterator()); It; ++It)
		if (AActor* Actor = Cast<AActor>(*It))

	int32 Index = 0;
	for (auto ActorIt = SelectionSetCache.CreateIterator(); ActorIt; ++ActorIt)
		AActor* Actor = *ActorIt;
		OnEachSelectedActor.Broadcast(Actor, Index);

Hi eXi and thanks for the info.

So using that function, how do I access the selected actor? I see it is broadcasting the Actor at Index, but how to I get a reference to the actual Actor?


You probably must declare custom delegate to match this criteria for it to work:

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( FForEachActorIteratorSignature, class AActor*, Actor, int32, Index );
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams( FForEachAssetIteratorSignature, class UObject*, Asset, int32, Index );

Then when you bind them blutility should execute code you specified on them… I did not tested this yet but plan to use this so I’m drilling through source to look at what it have to offer. UE4 would benefit great deal from more usage examples/documentation :slight_smile:

Try to look here for some ideas what can be done:GlobalEditorUtilityBase.h

Thanks Vertex Soup, I’ll look into that!

I found the ForEachSelectedActor in Blueprint. Even after reading above, I can not figure out how it works. Can someone show an example of it being used inside Blueprint ?

I don’t know if you still need this, but here’s an example.

Thanks, that looks pretty straight-forward!