Hi, I’m unable to serialize UTexture2DDynamic into array TArray which I would like to save to disk.
I’m using following structure as child of FArchive.
struct FImageArchive : public FObjectAndNameAsStringProxyArchive
{
FImageArchive (FArchive& InInnerArchive)
: FObjectAndNameAsStringProxyArchive(InInnerArchive, false)
{
ArIsSaveGame = true;
}
};
Structure may be problem as well, not sure what type of Archive use.
void MyClass::SerializeTexture(UTexture2DDynamic* Texture)
{
TArray<uint8> ObjectData;
if (Texture == nullptr) return nullptr;
FMemoryWriter MemoryWriter(ObjectData, true);
FImageArchive MyArchive(MemoryWriter);
Texture->Serialize(MyArchive);
// do something with TArray<uint8> data
}
But after serialization of texture, there aren’t valid data in my TArray. There are only 20 empty bytes and 4 bytes for “None” which doesn’t make sense to me.
Does anybody know how should I serialize texture properly ? This way doesn’t seem to work. Is Archive type wrong?
Could you at least point at any direction ?
Thanks, Jakub