# Blueprint structure can't be correctly saved (serialized)

**URL:** <https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099>\
**Category:** Editor Scripting\
**Tags:** savegame, Struct, serialization, unreal-engine, question\
**Created:** [July 15, 2016, 6:47am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099 "2016-07-15T06:47:26Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![marsonmao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@marsonmao](https://forums.unrealengine.com/u/marsonmao)\
**Post date:** [July 15, 2016, 6:47am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/1 "2016-07-15T06:47:26Z")

</div>

I’m using the Archive class to implement a save game system. My goal is to serialize any actor and its variables which enable the **SaveGame** property flag.

So I made an Archive inherits **FObjectAndNameAsStringProxyArchive** and set **ArIsSaveGame** to true, and I can enable the **SaveGame** of any varialbe and they are serialized.

But I found that this works inappropriate for the variables of Blueprint structure type. Even if I check the **SaveGame** for it, the members are not serialized.

My codes are like below:

```
struct FVRSaveGameArchive : public FObjectAndNameAsStringProxyArchive
{
    FMySaveGameArchive(FArchive& InInnerArchive)
        : FObjectAndNameAsStringProxyArchive(InInnerArchive, true)
    {
        ArIsSaveGame = true;
    }
};

FMemoryWriter MemoryWriter(record.data, true);
FMySaveGameArchive Ar(MemoryWriter);
actor->Serialize(Ar);

```

In this way all primitive type (integer, float…etc.) variables are saved correctly, but Blueprint structure type variables are not.

---

<div class="post-metadata">

**Author:** ![marsonmao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@marsonmao](https://forums.unrealengine.com/u/marsonmao)\
**Post date:** [July 15, 2016, 6:49am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/2 "2016-07-15T06:49:27Z")

</div>

Actually I found that the problem is here:

```
bool UProperty::ShouldSerializeValue( FArchive& Ar ) const
{
	if (Ar.ShouldSkipProperty(this))
		return false;

	if (Ar.IsSaveGame() && !(PropertyFlags & CPF_SaveGame))
		return false;

	static uint64 SkipFlags = CPF_Transient | CPF_DuplicateTransient | CPF_NonPIEDuplicateTransient | CPF_NonTransactional | CPF_Deprecated | CPF_DevelopmentAssets;
	if (!(PropertyFlags & SkipFlags))
		return true;

```

If my archive is Ar.IsSaveGame() == true, then the propery must be CPF\_SaveGame enabled, however the Blueprint structure properties are not enabled, so they can’t be saved. So I think UE should provide the way to enable CPF\_SaveGame for BP structure properties.

---

<div class="post-metadata">

**Author:** ![marsonmao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@marsonmao](https://forums.unrealengine.com/u/marsonmao)\
**Post date:** [July 22, 2016, 8:33am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/3 "2016-07-22T08:33:27Z")

</div>

Bump! Would like to know if Is this is intended/future work/won’t fix/real bug, thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [July 22, 2016, 1:07pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/4 "2016-07-22T13:07:10Z")

</div>

Hey,

Here is more information on serializing a struct:

[https://wiki.unrealengine.com/Save\_System,_Read_%26\_Write\_Any\_Data\_to\_Compressed\_Binary\_Files#Overloading\_the\_.3C.3C\_Operator](https://wiki.unrealengine.com/Save_System,_Read_%26_Write_Any_Data_to_Compressed_Binary_Files#Overloading_the_.3C.3C_Operator)

---

<div class="post-metadata">

**Author:** ![marsonmao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@marsonmao](https://forums.unrealengine.com/u/marsonmao)\
**Post date:** [July 28, 2016, 6:47am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/5 "2016-07-28T06:47:25Z")

</div>

Hi:  
Thanks for the link, I’ve already know that, and my question is about to serialize a Blueprint struct, not CPP struct. The question is how to serialize a Blueprint struct when Archive is set to ArIsSaveGame == true.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [July 29, 2016, 3:06pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/6 "2016-07-29T15:06:12Z")

</div>

Hey,

When it comes to saving Blueprint structs, I suggest following along with: [[https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/](https://docs.unrealengine.com/latest/INT/Gameplay/SaveGame/Blueprints/)][1]

Here are some screenshots of what I did:

**[Save Struct]**

 ![100682-452892_savebp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/c/c9c8d70fec4443db9ccb954e61f854a8b322ffac.png)

**[Load Struct]**

 ![100683-452892_loadbp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/8/8b8d4d9668b9031a8f80207d08fadd737924319e.png)

And then, Print out for the Save Struct:

 ![100684-452892_saveprint.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/2/202999126d9ac33b8f4d9de8797e0d98168633ba.png)

Finally, the Print out for loading what was saved:

 ![100685-452892_loadprint.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/4/b14c1f27af62443a90fa05048de91cfc17fbeda2.png)

If you are still having issues, update your post with what your problem is.

– Follow up

This works the same way in C++

**CSaveGame.h**

```
#pragma once

#include "GameFramework/SaveGame.h"
#include "CSaveGame.generated.h"

// Structure that is exposed to BP
USTRUCT(BlueprintType)
struct FTestStruct
{
	GENERATED_USTRUCT_BODY();

	UPROPERTY(BlueprintReadWrite)
	bool BoolVar;
	UPROPERTY(BlueprintReadWrite)
	int IntVar;
	UPROPERTY(BlueprintReadWrite)
	float FloatVar;
	UPROPERTY(BlueprintReadWrite)
	uint8 ByteVar;
	UPROPERTY(BlueprintReadWrite)
	FVector VectorVar;
	UPROPERTY(BlueprintReadWrite)
	FRotator RotatorVar;
	UPROPERTY(BlueprintReadWrite)
	FTransform TransformVar;
	UPROPERTY(BlueprintReadWrite)
	FString StringVar;
};

UCLASS()
class AH452892_API UCSaveGame : public USaveGame
{
	GENERATED_BODY()
	
public:
	UCSaveGame( );

	// ID for save game
	int UserId;

	// Slot name for save game
	FString SaveSlotName;
	
	// Data to save
	FTestStruct SavedTestStruct;	
};

```

**CSaveGame.cpp**

```
#include "AH452892.h"
#include "CSaveGame.h"

UCSaveGame::UCSaveGame( )
{
    // These can change and probably should with more complex games
	UserId = 1;
	SaveSlotName = FString( "UCSaveGame" );
}

```

**SerializeActor.h**

```
#pragma once

#include "GameFramework/Actor.h"

// Need CSaveGame for FtestStruct
#include "CSaveGame.h"

#include "SerializeActor.generated.h"

UCLASS()
class AH452892_API ASerializeActor : public AActor
{
	GENERATED_BODY()
	
public:	
	ASerializeActor();

	virtual void BeginPlay() override;

	// Local TestStruct data
	UPROPERTY(BlueprintReadWrite, SaveGame)
	FTestStruct TestStruct;

	// Save data to SaveGameObject
	UFUNCTION( BlueprintCallable, Category = "Save|Save Test Struct" )
	bool SaveTestStruct( FTestStruct In );

	// Load data from SaveGameObject
	UFUNCTION( BlueprintCallable, Category = "Save|Load Saved Test Struct" )
	FTestStruct LoadTestStruct( );
	
private:
	// Save game object
	USaveGame *SaveGameObject;
};

```

**SerializeActor.cpp**

```
#include "AH452892.h"
#include "SerializeActor.h"

ASerializeActor::ASerializeActor()
{
	// No need for this to tick
	PrimaryActorTick.bCanEverTick = false;
}

// On load
void ASerializeActor::BeginPlay()
{
	Super::BeginPlay();
	
	// Create SaveGameObject
	SaveGameObject = UGameplayStatics::CreateSaveGameObject( UCSaveGame::StaticClass( ) );
}

// Save test struct to our SaveGame
bool ASerializeActor::SaveTestStruct( FTestStruct In )
{
	if( SaveGameObject )
	{
		UCSaveGame *RealSaveGame = Cast<UCSaveGame>( SaveGameObject );
		if( RealSaveGame )
		{
			RealSaveGame->SavedTestStruct = In;
			return UGameplayStatics::SaveGameToSlot( RealSaveGame, RealSaveGame->SaveSlotName, RealSaveGame->UserId );
		}
	}
	return false;
}

// Load test struct from our SaveGame
FTestStruct ASerializeActor::LoadTestStruct( )
{
	if( SaveGameObject )
	{
		UCSaveGame *RealSaveGame = Cast<UCSaveGame>(SaveGameObject);
		if( RealSaveGame )
		{
			TestStruct = RealSaveGame->SavedTestStruct;
		}
	}

	return TestStruct;
}

```

After creating a child Blueprint class of SerializeActor, this is the Blueprint to save and load the Struct:

 ![100690-452892_loadsavebp.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/2/7f27d521793ab0c190ed2a9486cd92ab95423d68.png)

---

<div class="post-metadata">

**Author:** ![marsonmao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@marsonmao](https://forums.unrealengine.com/u/marsonmao)\
**Post date:** [August 1, 2016, 7:22am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/7 "2016-08-01T07:22:31Z")

</div>

Hi:  
Thanks for the very detailed answer, I really appreciate it. But please note one very important point, I am using my custom `FArchive` to do the serialization, which is different with the default one used by `UGameplayStatics`’s functions. My custom `FArchive` has set `Ar.IsSaveGame` to true, which leads to another way of the execution, so in that way the BP struct can’t be saved properly.

---

<div class="post-metadata">

**Author:** ![marsonmao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@marsonmao](https://forums.unrealengine.com/u/marsonmao)\
**Post date:** [August 1, 2016, 7:27am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/8 "2016-08-01T07:27:49Z")

</div>

Please check this link [link text](https://answers.unrealengine.com/questions/35618/savingloading-an-array-of-objects.html?sort=oldest), the 14 upvoted answer. My custom `FArchive` is like the `FFortniteSaveGameArchive ` example, and with it I can’t save BP struct.

---

<div class="post-metadata">

**Author:** ![luca.ferrara](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@luca.ferrara](https://forums.unrealengine.com/u/luca.ferrara)\
**Post date:** [August 2, 2016, 4:00pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/9 "2016-08-02T16:00:20Z")

</div>

Hi, I’ve exactly the same problem. The issue seems to be that the SaveGame flag is not inherited from struct members.

I hope that behavior will be fixed in the future but in the meanwhile instead of structs I’m using classes that inherits from Object and containing only public members. That works fine and moreover it’s possible to set save / transient flags on each ‘class’ member.

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [August 30, 2016, 3:25pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/10 "2016-08-30T15:25:24Z")

</div>

I have the same problem 🙂

---

<div class="post-metadata">

**Author:** ![skeleton60](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@skeleton60](https://forums.unrealengine.com/u/skeleton60)\
**Post date:** [September 24, 2016, 11:24pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/11 "2016-09-24T23:24:42Z")

</div>

Same problem and we may need a issue number to track this

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_61b4a355](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_61b4a355](https://forums.unrealengine.com/u/anonymous_user_61b4a355)\
**Post date:** [September 26, 2016, 1:01pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/12 "2016-09-26T13:01:19Z")

</div>

If you are having an issue where the answer here isn’t related, please make a new post in Bug Reports and give detailed steps on how to reproduce it. Here is a guideline on how to write up an issue:

[https://answers.unrealengine.com/questions/12363/how-do-i-report-a-bug.html](https://answers.unrealengine.com/questions/12363/how-do-i-report-a-bug.html)

Thanks.

---

<div class="post-metadata">

**Author:** ![BrUnO\_XaVIeR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bruno_xavier/32/1110230_2.png) [@BrUnO\_XaVIeR](https://forums.unrealengine.com/u/BrUnO_XaVIeR)\
**Post date:** [April 22, 2018, 10:51am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/13 "2018-04-22T10:51:06Z")

</div>

Coming back to this problem again this month;  
For my projects I solved this issue by completely discarding use of FArchive classes and avoiding the Serialize() methods.

I’ve created my own serializer based on UProperty reflection + JSON to replace the ProxyArchive class.  
Now I can finally read/write to structs created as Blueprint assets (user defined structs).

---

<div class="post-metadata">

**Author:** ![Flashback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Flashback](https://forums.unrealengine.com/u/Flashback)\
**Post date:** [June 25, 2019, 1:00pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/14 "2019-06-25T13:00:44Z")

</div>

Still not fixed in 2019, unfortunately ☹

---

<div class="post-metadata">

**Author:** ![laggyluk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@laggyluk](https://forums.unrealengine.com/u/laggyluk)\
**Post date:** [August 1, 2022, 6:53pm UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/15 "2022-08-01T18:53:06Z")

</div>

fixed in 2022 😉 although since I’m here it might be worth to mention that each field of struct in it’s properties has to have ‘save game’ checked, setting it only on struct field is not enough.

---

<div class="post-metadata">

**Author:** ![0b99a19b9b554e578b2f44ba67fc40bc](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/0b99a19b9b554e578b2f44ba67fc40bc/32/912584_2.png) [@0b99a19b9b554e578b2f44ba67fc40bc](https://forums.unrealengine.com/u/0b99a19b9b554e578b2f44ba67fc40bc)\
**Post date:** [April 7, 2024, 2:33am UTC](https://forums.unrealengine.com/t/blueprint-structure-cant-be-correctly-saved-serialized/364099/16 "2024-04-07T02:33:40Z")

</div>

For me this is the solution,Thanks,Whether you are defining a C++ structure or a blueprint structure, you need to check SaveGameFlag For MemberProperties that need to be saved. For the blueprint structure, click the button next to the MemberProperty of structure to expand the drop-down list. You can see the checkBox of SaveGameFlag. For the C++ structure, select the member properties that need to be saved. Just write SaveGame in UPROPERTY().
