Allow Sparse Class Data on components created via C++

I have a habbit of creating components in my Actor’s constructor, so that the reference is obtained automatically, and also to ease the creation of blueprints.

However I have found that Sparse Class Data on components added in the constructor are not functioning properly. In particular in the Blueprint Editor, AttributesClass does not appear even though it is marked as EditDefaultsOnly (I repeat I am in the Blueprint Editor for my character, I am not looking at the character from the world hierarchy).

I think that this should be fixed no?

MyGameCharacter.cpp


AMyGameCharacter::AMyGameCharacter()

: Super()

{

...

Attributes = CreateDefaultSubobject<UMyGameAttributesComponent>(TEXT("MyGameAttributesComponent"));

}

MyGameAttributesComponent.h


USTRUCT(BlueprintType)

struct MyGame_API FMyGameAttributesComponentClassData

{

GENERATED_BODY()

public:

UPROPERTY(EditDefaultsOnly, Category = "MyGame", meta = (GetByRef))

TSubclassOf<UMyGameAttributeSet> AttributesClass;

};

UCLASS(BlueprintType, SparseClassDataTypes = MyGameAttributesComponentClassData, ClassGroup=MyGame, meta=(BlueprintSpawnableComponent))

class MyGame_API UMyGameAttributesComponent : public UMyGameActorComponent

{

GENERATED_BODY()

public:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "MyGame")

UMyGameAttributeSet* Attributes = nullptr;

Further note about this bug, is that simply moving the UPROPERTY in the class as opposed to the sparse class data, so it isn’t an issue of semantics with EditDefaultsOnly.

Hire me and I will fix all your bugs. I am a former Autodesk software developer working on Maya with 3 years of experience. I will do QA or dev work at Epic. We can start me off on a contract or an internship. Thanks