But, then we need to do for each possible camera class. This somehow seems redundant. Am I missing something here? Afaik, there is no common base class.
Since they both derive from USceneComponent, I would try a GetComponents<USceneComponent> and then identifying which type in a for loop for the output. Here is an example where all things derived from a USceneComponent are returned regardless of what type of component they are.
That works, here is a test, tossing in this crude code to what I had above:
if(Cast<UStaticMeshComponent>(scompswpt*)) {
UE_LOG(LogTemp,Warning,TEXT("%s is a UStaticMeshComponent."),*scompswpt*->GetName());
}
if(Cast<UChildActorComponent>(scompswpt*)) {
UE_LOG(LogTemp,Warning,TEXT("%s is a UChildActorComponent."),*scompswpt*->GetName());
}
I get this.
LogTemp: Warning: Cube is a UStaticMeshComponent.
LogTemp: Warning: Waypoint1 is a UChildActorComponent.
LogTemp: Warning: Sphere is a UStaticMeshComponent.
LogTemp: Warning: Waypoint2 is a UChildActorComponent.
...
This is not correct because you are comparing the name of the component, which can be anything. In your example you can see that SMComponents are named Cube and Sphere, so this comparison doesn’t work.
Cube or Sphere is the name of component and is named or defaulted by us, StaticMeshComponent is the name returned of the class so it will be consistent. In my examples, these would be ChildActorComponent, StaticMeshComponent and SceneComponent. They are the class names but without the U at the front, the class name you would see if you hovered over the object in the blueprint hierarchy. The class name returned by “MyFPSCamera” (if it were a UCameraComponent) should be CameraComponent.