Download

How to Cast an Iterator?

I am using an Iterator to loop over all light components, like so:


for(TObjectIterator<ULightComponent> Light; Light; ++Light)
{
    // ...
}

Now I want to cast the Iterator to a point light.
I tried it with something like this:


UPointLightComponent* PointLight = Cast<UPointLightComponent>(Light);

But that doesn’t work.
Any ideas how I can perform this cast correctly?


UPointLightComponent* PointLight = Cast<UPointLightComponent>(*Light); // note that * in front of a name of your Iterator.

Weird, I am quite sure I tried that.
Well, but thank you very much nevertheless :slight_smile: