How would you write code that can handle a generic object type? Would you use a template?
I’m trying to figure out how I’d have a class that can have a member that might be a UStaticMesh, a UStaticMeshComponent, a ULightComponent, etc. I’m guessing the answer is to use a template somehow, but I’m not sure exactly how to structure it. I also wonder if UE has a way of handling this.
Sorry if that’s rambling, I’m still getting my head around this.
You probably just want a property that is of common base class type. For example:
UPROPERTY(...)
USceneComponent* GenericComponent;
How you would instantiate it is another matter. You can’t just do it in the constructor since you obviously need it to vary based on some condition. Depending on what your aim is, I guess you’d want to create the component in either OnConstruction or PostInitComponents/BeginPlay.