I was creating a sub-object inside my actor’s constructor the usual way:
AMyActor::AMyActor(const FObjectInitializer &init) : Super(init)
{
text_render = CreateDefaultSubobject<UTextRenderComponent>(TEXT("info_text"));
}
Worked fine. Then I needed to move this creation into a member object of the actor and do this creation outside the constructor. The recommended approach was to use NewObject:
SomeMemberOfMyActor::init()
{
text_render = NewObject<UTextRenderComponent>(m_owner, TEXT("info_text"));
}
This compiles and runs and creates the component, but it’s invisible. It seems like that second parameter is wrong – it should be a “UClass” instead of a text string. But what “UClass” would I use for a text render component?