FMemoryArchive doesn't support UObject properties?

How to avoid crashing when saving an object with UObject properties to the FMemoryWriter archive?

I was crashed here:

	virtual FArchive& operator<<( class UObject*& Res ) override
	{
		// Not supported through this archive
		check(0);
		return *this;
	}

While doing this:

		ModuleSerializedData.Empty();
		FMemoryWriter WriteStaticInfo(ModuleSerializedData);
		ThisClass->SerializeBinEx(WriteStaticInfo, ModuleCDO, ThisClass->GetDefaultObject(), ThisClass);
1 Like

There are a bunch of different archivers which seem to be specialized for serializing different data.
Have you tried an FObjectWriter? (It’s a child class of FMemoryWriter)

Thanks, it seems that it is better archive to my data. But, unfortunately, I have data to survive through the network\savegame serialization. This archive just saves pointers as is. Actually I just need to bake a node template to the binary (and zip it then) and restore it next time

When you say it saves poitners as-is, do you mean that when you serialize a UOBject it’s just serializing a pointer to that object, or do you mean all the UObject* properties on the object you’re serializing just get saved as pointers and then are subsequently useless (since across different machines and save/load the memory addresses they point to no longer contain the target object)?

It serializes all non-uobject properties as it does FWriteArchive, and serializes UObject properties as pointers. Actually I found an alternative way to bake my object. At first I extract all UObjects using FArchiveObjectPropertyMapper and put them into a special array of UObjects with path placed in my asset. Then I save all other properties using FObjectWriter. To recover data when loading I have to read baked content using FObjectReader, and then patch UObject properties from the object array.

Hi c4tnt! I have run into a very similar issue, trying to save a UTexture2D* (child of UObject) into an FArchive to store on disk, and later re-create the exact object from the file.

I can’t seem to figure out how to use FArhciveObjectPropertyMapper, or which type of archive can save not only the reference, but the actual data inside the UObject.

Would you please point me in the right direction? Can’t seem to find any examples, beyond your answer here.