Care and feeding of USaveGame

Hi guys, a few questions I didn’t see documented anywhere:

1.) Are only the UPROPERTY-marked fields inside the USaveGame class serialized?
2.) Can the system serialize TArrays? (i.e. does the class have to have an apriori fixed size? it seems to handle FStrings so it must be dynamic in some ways)

I’d like to have a bunch of data in structs and then have an array of those, i.e. an array of data for each player character, and each character has things like XP, weapon loadouts, etc. So far it appears that anything inside my TArray doesn’t get written out to the file. The documentation only goes over the very simplest of cases (saving a single int etc.)

Thanks,

dave grace

Figured it out. The trick is that you can have TArrays of structs that are defined with USTRUCT syntax, like:

USTRUCT()
struct FSaveGameCharInfo
{
   GENERATED_USTRUCT_BODY()

   UPROPERTY() int32 XP;
   ...
};

UCLASS()
class TRONGAME_API UMySaveGame : public USaveGame
{
	GENERATED_UCLASS_BODY()

	UPROPERTY()	TArray Chars;
};

Hi,

We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.

Thanks!

Sure, I thought it was public already. Cheers!

dave