You need to add a billboard component to your object in the class constructor:
AMyClass::AMyClass(const FObjectInitializer& Init) : Super(Init)
{
//Add root component
USceneComponent* SceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneComp"));
RootComponent = SceneComponent;
//Add billboard component
UBillboardComponent* SpriteComponent = CreateEditorOnlyDefaultSubobject<UBillboardComponent>(TEXT("Sprite"));
// Structure to hold one-time initialization
struct FConstructorStatics
{
ConstructorHelpers::FObjectFinderOptional<UTexture2D> DecalTexture;
FConstructorStatics() : DecalTexture(TEXT("/Engine/Editor/Slate/Icons/AssetIcons/Sphere_64x.Sphere_64x")) {}
};
static FConstructorStatics ConstructorStatics;
// Set up sprite component
if (SpriteComponent)
{
SpriteComponent->Sprite = ConstructorStatics.DecalTexture.Get();
SpriteComponent->SetupAttachment(RootComponent);
SpriteComponent->SetUsingAbsoluteScale(true);
SpriteComponent->bIsScreenSizeScaled = true;
SpriteComponent->bReceivesDecals = false;
SpriteComponent->bHiddenInGame = true;
}
}
Thank you, awesome help!