Blueprint Component with Billboard no render

I have procedural level generation, so the game level is spawned at runtime. It’s not completely procedural, the designer makes Blocks which are Blueprints, which are then spawned in. The blocks have components on them that are used to spawn the other actors.

The components have a C++ base class, which inherit from a common parent extending USceneComponent. This class has:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Marker")
	class UBillboardComponent* BillboardComponent;

I was originally setting it with a sprite in the constructor, but that only worked in the Editor. Running standalone or trying to package crash and fail. THere are notes in the documentation that say it is not correct to initialize to assets in the constructor anyway.

So, I made the Billboard a UPROPERTY. I’d like to set this in a Blueprint base for each type of marker, so when added to an Actor Blueprint the component allready has a Billboard with a Sprite specified.

This doesn’t seem to work. The base class doesn’t accept the sprite being set, and in the instance, setting the sprite has no effect as it then isn’t rendered.

The following works in the constructor of a class extending UScenecomponent.

But, doing it like this crashes the game in standalone play, it only will run in Editor like this.


// Structure to hold one-time initialization
struct FConstructorStatics
	// A helper class object we use to find target UTexture2D object in resource package
	ConstructorHelpers::FObjectFinder<UTexture2D> Texture0;
		: Texture0(TEXT("Texture2D'/Game/Procedural/Blocks/Blueprints/icons/TokenMarker'"))
static FConstructorStatics ConstructorStatics;

BillboardComponent = ObjectInitializer.CreateEditorOnlyDefaultSubobject<UBillboardComponent>(this, TEXT("Billboard"), true);

SpriteTexture = ConstructorStatics.Texture0.Object;
BillboardComponent->Sprite = SpriteTexture;