can't save UPROPERTY values

Hello World!

My GameMode has UPROPERTY of UObject derived type

UPROPERTY(EditAnywhere, meta = (AllowPrivateAccess = true))
UPlayerManager* PlayerManager;

I init this property in constructor

PlayerManager = CreateDefaultSubobject<UPlayerManager>(TEXT("PlayerManager"));

PlayerManager declared like i show below, and this object has simple TMap with UENUM key and TSubclassOf value

class C77_API UPlayerManager : public UObject

enum class EPlayerType : uint8
    Play UMETA(DisplayName = "Play"),
    Dead UMETA(DisplayName = "Dead"),

    First = Play,
    Last = Dead

UPROPERTY(EditAnywhere, Category = "PlayerManager", meta = (AllowPrivateAccess = true))
    TMap<EPlayerType, TSubclassOf<APawn>> PlayerClasses;

So, after i recompile my project and try to edit PlayerManager property in my game mode BP i can’t save them. I tried to press save button inside PlayerManager object editor, and inside GameMode editor, also i tried SaveAll and GameMode blueprint recompilation. But, after i close and open project again, values of PlayerManager field dropped to default.


I’m not sure if you’re editing the same PlayerManager object as the one you’re creating in

PlayerManager = CreateDefaultSubobject<UPlayerManager>(TEXT("PlayerManager"));

because you’ve declared the UPlayerManager* as EditAnywhere, which means the editor can change the object it points to (to some on-the-fly instance, perhaps). Try making it VisibleAnywhere, which makes the pointer uneditable and should make the PlayerManager’s properties editable in the GameMode’s own details panel.

I would like suggest you take a look the serialization of UObject, that could be the reason of you can’t save those properties.