struct FParameter
{
public:
int Arg1;
int Arg2;
TSoftObjectPtr<UObject> Object;
public:
TArray<uint8> AsByteArray()
{
TArray<uint8> byteArray;
FMemoryWriter Ar(byteArray);
Ar << const_cast<FB2Parameter&>(*this);
return Ar;
}
friend FArchive& operator<<(FArchive& Ar, FB2Parameter& InParam)
{
Ar << InParam.Arg1;
Ar << InParam.Arg2;
// SoftObject는 path만 메모리에 read&write함.
if(Ar.IsLoading())
{
InParam.Object.ResetWeakPtr();
}
FSoftObjectPath& path = const_cast<FSoftObjectPath&>(InParam.Object.ToSoftObjectPath());
InParam.Object.SerializePath(Ar);
return Ar;
}
}
void main()
{
FParameter param;
param.Arg1 = 1;
param.Arg2 = 2;
param.Object = NewObject<UObject>();
// FVariant에 FB2Parameter byte array를 넘긴다.
FVariant(param.AsByteArray());
}