How it works...

We create an array of pointers to MyInterface implementations.

Inside BeginPlay, we use TActorIterator<AActor> to get all of the Actor instances in our level.

TActorIterator has the following constructor:

explicit TActorIterator( UWorld* InWorld, 
TSubclassOf<ActorType>InClass = ActorType::StaticClass() ) : Super(InWorld, InClass )

TActorIterator expects a world to act on, as well as a UClass instance to specify what types of Actor we are interested in.

ActorIterator is an iterator like the STL iterator type. This means that we can write a for loop in the following form:

for (iterator-constructor;iterator;++iterator) 

Inside the loop, we dereference the iterator to get an Actor pointer.

We then attempt to cast it to our interface; this will return a pointer to the interface if it does implement it, otherwise it will return nullptr.

As a result, we can check if the interface pointer is null, and if not, we can add the interface pointer reference to our array.

Finally, once we've iterated through all the actors in TActorIterator, we can display a message on the screen that displays the count of items that implemented the interface.