I’m iterating over all instances of a component type from an Actor’s code using the following code:
for (TObjectIterator<UMyComponent> iter; iter; ++iter)
{
if (iter->GetWorld() == GetWorld())
{
myComp = *iter;
if (myComp!= nullptr && myComp->HasBeenCreated())
{
//DO STUFF
}
}
}
The reason I use test for HasBeenCreated() is to filter out instances of my component that Unreal automatically created with a GEN_VARIABLE suffix. I tried using the RF_WasLoaded flag on the iterator which works but that also sometimes filters out the component that is actually in an object placed in my map.
Am I missing something here or is that a proper way of filtering out those GEN_VARIABLE instances? Are those GEN_VARIABLE instances also there in the shipping game?
Any help or clarification on this would be useful.
Thanks!