Better Way to Deduce Object Type ?

Hi guys, I’m working on a plugin code to be running in editor.

I want to know what type of object is selected. Options are : PointLight,

One way to do is casting object, but I think there should be a smarter way of it.
Any one has any idea ?

My code is:

AActor* selectedActor = GEditor->GetSelectedActors()->GetTop<AActor>();

APointLight* PointLightActor = Cast<APointLight>(selectedActor);

if (PointLightActor != nullptr)
UE_LOG(LogTemp, Warning, TEXT("Found Point Light Actor !"));

If I get 1 actor from GetSelectedActors function , what could be best way to know which class this object is from , apart from trying casting

Casting is too expensive.

Try “IsA()”:

if ( selectedActor->IsA( APointLight::StaticClass() )

Correct Sir! I didn’t thought about it.