Issue on serialize FTransform Property to byte stream

Asahi_86
Thu, 25 Feb 2021 01:41:37 +0000
Editor Scripting

I have made a UStruct like this:

USTRUCT(BlueprintType)
struct FTestLocation
{
	GENERATED_BODY()

	UPROPERTY()
	int32 Value = 0;

	UPROPERTY()
	FTransform Transfrom;

	UPROPERTY()
	float Value2 = 0;
};

And I am trying to serialize/deserialize with a Buffer.

FBufferArchive SavingStream;
FTestLocation SaveLocation;
SaveLocation.Value = 1;
SaveLocation.Transfrom.SetLocation({2.f, 2.f, 2.f});
SaveLocation.Value2 = 3.f;
FTestLocation::StaticStruct()->SerializeBin(SavingStream, &SaveLocation);

FBufferReader LoadingStream(SavingStream.GetData(), SavingStream.Num(), false);
FTestLocation LoadLocation;
FTestLocation::StaticStruct()->SerializeBin(LoadingStream, &LoadLocation);

The issue is: after the Loading process,

LoadLocation.Value is loaded correctly,

LoadLocation.Transfrom is not updated at all.

LoadLocation.Value2 is clearly a trash value.

Can anyone let me know what I did wrong?

4 posts - 1 participant