Can you save a TMap in c++

I’m trying to save a list of items that contains information like transform and if they should be spawned.
Because an actor will check it’s saved state when it’s spawned i want to use a TMap for faster lookups.

But the TMap isn’t saved while other properties are saved.

This is my USaveGame:

USTRUCT()
struct FEnemySave{
	GENERATED_USTRUCT_BODY()

	UPROPERTY()
	FName Id;
	UPROPERTY()
	bool Death;
};

USTRUCT()
struct FPlayerSave{
	GENERATED_USTRUCT_BODY()

	UPROPERTY()
	int8 Level;
	UPROPERTY()
	FVector Position;
	UPROPERTY()
	FRotator Rotation;
};

USTRUCT()
struct FSave{
	GENERATED_USTRUCT_BODY()

	UPROPERTY()
	FString PlayerName;

	//UPROPERTY()
	TMap<FName, FEnemySave> Enemies;

	UPROPERTY()
	FPlayerSave Player;
};

/**
 * 
 */
UCLASS()
class MOONSHINEWORKS_API UMOOSaveGame : public USaveGame
{
	GENERATED_UCLASS_BODY()

public:
	UPROPERTY(VisibleAnywhere, Category = MOO)
	FSave Data;
};

I noticed that when i don’t set the UPROPERTY on a value it stops saving corretly but i can’t use tge UPROPERTY for the TMap.

Edit: Removed a stupid comment from code.

#Create Your Own Save System

You can read and write any data you want to compressed binary file using my Compressed Binary Save System Tutorial!

Wiki: Read and Write any Data To Compressed Binary File
A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums,Read%26_Write_Any_Data_to_Compressed_Binary_Files

I use what I show you in this tutorial in Solus and all my other projects to save any data I want to disk, from low level data types that can’t be made UPROPERTY() all the way up to complex USTRUCTS and AActors that are game-specific

And ultimately I save entire levels for my in-game editor using this system I am giving to you for free!

#:heart:

Rama

Hey thanks for the answers.
I’m a bit new in c++ so i wanted to avoid writing to much custom code but your tutorial looks very comprehensible :smiley:

Thank you very much :heart: