Serialization of FDataTableRowHandle

I’ve run into something that I can’t seem to figure on a good solution for.
I have a blueprints with an array of UStruct objects of which I use to randomize and add as attributes for my NPCs.
These attributes are made by our designers and I have set them up to load the required data using a FDataTableRowHandle.

USTRUCT(BlueprintType)
struct FNpcAttribute
{
	virtual void MySerialize(FArchive& Ar);

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NpcPassion)
	FDataTableRowHandle target_;
}

void FNpcAttribute::MySerialize(FArchive& Ar) {
	FName rowName = target_.RowName;
	const UDataTable* table = target_.DataTable;
	ar << rowName;
	ar << table; // not sure what to do here?
	if( Ar.IsLoading() ) {
		target_.RowName = rowName;
		target_.DataTable = table;
	}
}
UCLASS()
class ANpc : public AActor
{
	virtual void MySerialize(FArchive& Ar);
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Npc)
	TArray<FNpcAttribute> Attributes;
}
void ANpc::MySerialize(FArchive& Ar) {
	for (auto attribute : Attributes) {
		attribute.MySerialize(Ar);
	}
}

I get issue during the ar << table; and I’m unsure what I need to do to?
I have options, but I’m hoping for a way to easily reserialize the object to point to the same UDataTable* it did previously?

The solution I went with for this was to have all my tables indexed into a seperate ‘Table of Contents’ of which I then serialized the chapter I was reading from and the row name from the attribute.

1 Like