UPROPERTY's Reset on Compile

Hey,
I have a subclass of USceneComponent with a few UPROPERTY’s whose defaults are meant to be set in the properties panel of a blueprint. Every time I make a change to the code of the component – including when there are no changes in the header – the values set in blueprint reset to the default values.

Here is a minimal example of a component that has the issue for me:

UCLASS( ClassGroup=(Test), meta=(BlueprintSpawnableComponent) )
class GAME_API UTestComponent : public USceneComponent {

    GENERATED_UCLASS_BODY()

    public:
        UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = Test)
        TArray<float> TestArray;
}

The problem is persisting both when I close the editor and compile, when I use hot reload compiling through my IDE and when using hot load when compiling from the editor.

EditDefaultsOnly could be the cause for your issue. I think it’s meant to edit all instances of your UTestComponent. If you don’t need it, try removing it. Also, if this is meant to be set in blueprint, you might need BlueprintReadWrite instead.

I tried replacing both EditDefaultsOnly and BluepringReadOnly with your suggestions but nothing changed. I think By setting the values in blueprint I meant the defaults through the properties tab, I will update the question to reflect that

Add Instanced as an UPROPERTY

3 Likes