Download

Set UProperty value in c++ while in editor but i can't save it

Is there any way to set default object’s property in c++? I’ve tried to set property value but it doesn’t saved.
I want to set property values of bp class derived from my cpp class. And I’ve set one property value when other property changed in PostEditChange.
It changes value directly but it can’t be saved. When I save and close editor, reopen it, those property values I set was cleared.
Property values saved form editor directly were saved fine, but only edited from code was cleared.

Struct Codes

USTRUCT(Blueprintable)
struct FCanvasSlotData
{
	GENERATED_USTRUCT_BODY()

public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite) FAnchors Anchors;
	UPROPERTY(EditAnywhere, BlueprintReadWrite) FMargin Offset;
	UPROPERTY(EditAnywhere, BlueprintReadWrite) FVector2D Alignment;
};

Code from PostEditChange()

FCanvasSlotData newSlotData;
newSlotData.Anchors = currentSlot->GetAnchors();
newSlotData.Offset = currentSlot->GetOffsets();
newSlotData.Alignment = currentSlot->GetAlignment();
		
FObjectEditorUtils::SetPropertyValue<UCustomCanvasPanel, FCanvasSlotData>(this, FName("LandscapeSlot"), newSlotData);

But I want to change it on editor editing.
It saves landscape and portrait layout when layout changed, since they could be saved while in editing layout and saved when screen orientation changed.
Is there anyway to set default in editor?