Header:
class FE_API AFEObject : public AActor
{
GENERATED_UCLASS_BODY()
UPROPERTY(VisibleDefaultsOnly, Category = Object)
TSubobjectPtr<class UCapsuleComponent> Capsule;
UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
TSubobjectPtr<class USkeletalMeshComponent> Mesh;
UPROPERTY(VisibleDefaultsOnly, Category = Text)
TSubobjectPtr<class UTextRenderComponent> FloatingText;
};
CPP:
AFEObject::AFEObject(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
Capsule = PCIP.CreateDefaultSubobject<UCapsuleComponent>(this, TEXT("Capsule"));
this->SetRootComponent(Capsule);
Mesh = PCIP.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("ObjectMesh"));
Mesh->AttachParent = Capsule;
FloatingText = PCIP.CreateDefaultSubobject<UTextRenderComponent>(this, TEXT("ObjectMesh"));
}
The error is:
error C2439: ‘TSubobjectPtrConstructor::Object’ : member could not be initialized
error C2440: ‘initializing’ : cannot convert from ‘UTextRenderComponent *’ to ‘UObject *’
I checked the docs and it says UTextRenderComponent is a UObject, so I don’t understand what the problem is.