How serialize array of custom UObject?

I’m trying to serialize an Array of “UBlock” UObjects, I tried overloading the “Serialize” function and adding a custom operator<< but got the same error:

[2/6] Compile [x64] BlockArray3D.cpp
11>Array.h(3763): Error C2679 : binary '<<': no operator found which takes a right-hand operand of type 'UBlock *' (or there is no acceptable conversion)
11>Archive.h(1284): Reference C2679 : could be 'FArchive &FArchive::operator <<(FWeakObjectPtr &)'
11>Archive.h(1274): Reference C2679 : or       'FArchive &FArchive::operator <<(FSoftObjectPath &)'
11>Archive.h(1266): Reference C2679 : or       'FArchive &FArchive::operator <<(FSoftObjectPtr &)'
11>Archive.h(1256): Reference C2679 : or       'FArchive &FArchive::operator <<(FObjectPtr &)'
11>Archive.h(1246): Reference C2679 : or       'FArchive &FArchive::operator <<(FLazyObjectPtr &)'
11>Archive.h(1190): Reference C2679 : or       'FArchive &FArchive::operator <<(FField *&)'
11>Archive.h(1177): Reference C2679 : or       'FArchive &FArchive::operator <<(UObject *&)'
11>Archive.h(1167): Reference C2679 : or       'FArchive &FArchive::operator <<(FText &)'
11>Archive.h(1156): Reference C2679 : or       'FArchive &FArchive::operator <<(FName &)'
11>Archive.h(1299): Reference C2679 : or       'FArchive &operator <<(FArchive &,ANSICHAR &)' [found using argument-dependent lookup]
11>Archive.h(1316): Reference C2679 : or       'FArchive &operator <<(FArchive &,WIDECHAR &)' [found using argument-dependent lookup]
11>Archive.h(1333): Reference C2679 : or       'FArchive &operator <<(FArchive &,uint8 &)' [found using argument-dependent lookup]
11>Archive.h(1350): Reference C2679 : or       'FArchive &operator <<(FArchive &,int8 &)' [found using argument-dependent lookup]
11>Archive.h(1367): Reference C2679 : or       'FArchive &operator <<(FArchive &,uint16 &)' [found using argument-dependent lookup]
11>Archive.h(1384): Reference C2679 : or       'FArchive &operator <<(FArchive &,int16 &)' [found using argument-dependent lookup]
11>Archive.h(1401): Reference C2679 : or       'FArchive &operator <<(FArchive &,uint32 &)' [found using argument-dependent lookup]
11>Archive.h(1422): Reference C2679 : or       'FArchive &operator <<(FArchive &,bool &)' [found using argument-dependent lookup]
11>Archive.h(1461): Reference C2679 : or       'FArchive &operator <<(FArchive &,int32 &)' [found using argument-dependent lookup]
11>Archive.h(1497): Reference C2679 : or       'FArchive &operator <<(FArchive &,float &)' [found using argument-dependent lookup]
11>Archive.h(1515): Reference C2679 : or       'FArchive &operator <<(FArchive &,double &)' [found using argument-dependent lookup]
11>Archive.h(1533): Reference C2679 : or       'FArchive &operator <<(FArchive &,uint64 &)' [found using argument-dependent lookup]
11>Archive.h(1550): Reference C2679 : or       'FArchive &operator <<(FArchive &,int64 &)' [found using argument-dependent lookup]
11>Archive.h(1567): Reference C2679 : or       'FArchive &operator <<(FArchive &,FIntRect &)' [found using argument-dependent lookup]
11>Archive.h(1575): Reference C2679 : or       'FArchive &operator <<(FArchive &,FString &)' [found using argument-dependent lookup]
11>StringBuilder.h(458): Reference C2679 : or       'FAnsiStringBuilderBase &operator <<(FAnsiStringBuilderBase &,ANSICHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(459): Reference C2679 : or       'FAnsiStringBuilderBase &operator <<(FAnsiStringBuilderBase &,UTF8CHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(460): Reference C2679 : or       'FAnsiStringBuilderBase &operator <<(FAnsiStringBuilderBase &,WIDECHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(461): Reference C2679 : or       'FWideStringBuilderBase &operator <<(FWideStringBuilderBase &,ANSICHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(462): Reference C2679 : or       'FWideStringBuilderBase &operator <<(FWideStringBuilderBase &,UTF8CHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(463): Reference C2679 : or       'FWideStringBuilderBase &operator <<(FWideStringBuilderBase &,WIDECHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(464): Reference C2679 : or       'FUtf8StringBuilderBase &operator <<(FUtf8StringBuilderBase &,ANSICHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(465): Reference C2679 : or       'FUtf8StringBuilderBase &operator <<(FUtf8StringBuilderBase &,UTF8CHAR)' [found using argument-dependent lookup]
11>StringBuilder.h(466): Reference C2679 : or       'FUtf8StringBuilderBase &operator <<(FUtf8StringBuilderBase &,WIDECHAR)' [found using argument-dependent lookup]
11>NameTypes.h(1512): Reference C2679 : or       'FWideStringBuilderBase &operator <<(FWideStringBuilderBase &,const FName &)' [found using argument-dependent lookup]
11>NameTypes.h(1518): Reference C2679 : or       'FUtf8StringBuilderBase &operator <<(FUtf8StringBuilderBase &,const FName &)' [found using argument-dependent lookup]
11>NameTypes.h(1524): Reference C2679 : or       'FWideStringBuilderBase &operator <<(FWideStringBuilderBase &,FNameEntryId)' [found using argument-dependent lookup]
11>NameTypes.h(1525): Reference C2679 : or       'FUtf8StringBuilderBase &operator <<(FUtf8StringBuilderBase &,FNameEntryId)' [found using argument-dependent lookup]
11>GatherableTextData.h(37): Reference C2679 : or       'FArchive &operator <<(FArchive &,FTextSourceData &)' [found using argument-dependent lookup]
11>GatherableTextData.h(38): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot,FTextSourceData &)' [found using argument-dependent lookup]
11>Script.h(171): Reference C2679 : or       'FArchive &operator <<(FArchive &,EFunctionFlags &)' [found using argument-dependent lookup]
11>PrimaryAssetId.h(205): Reference C2679 : or       'FStringBuilderBase &operator <<(FStringBuilderBase &,const FPrimaryAssetId &)' [found using argument-dependent lookup]
11>TopLevelAssetPath.h(182): Reference C2679 : or       'FStringBuilderBase &operator <<(FStringBuilderBase &,const FTopLevelAssetPath &)' [found using argument-dependent lookup]
11>SoftObjectPath.h(373): Reference C2679 : or       'FStringBuilderBase &operator <<(FStringBuilderBase &,const FSoftObjectPath &)' [found using argument-dependent lookup]
11>BulkData.h(184): Reference C2679 : or       'FArchive &operator <<(FArchive &,EBulkDataFlags &)' [found using argument-dependent lookup]
11>ShaderCore.h(374): Reference C2679 : or       'FArchive &operator <<(FArchive &,FShaderResourceTable &)' [found using argument-dependent lookup]
11>ShaderCore.h(386): Reference C2679 : or       'FArchive &operator <<(FArchive &,FUniformResourceEntry &)' [found using argument-dependent lookup]
11>ShaderCore.h(399): Reference C2679 : or       'FArchive &operator <<(FArchive &,FUniformBufferEntry &)' [found using argument-dependent lookup]
11>ShaderCore.h(831): Reference C2679 : or       'FArchive &operator <<(FArchive &,FShaderCodeValidationStride &)' [found using argument-dependent lookup]
11>ShaderCore.h(836): Reference C2679 : or       'FArchive &operator <<(FArchive &,FShaderCodeValidationType &)' [found using argument-dependent lookup]
11>ShaderCore.h(841): Reference C2679 : or       'FArchive &operator <<(FArchive &,FShaderCodeValidationUBSize &)' [found using argument-dependent lookup]
11>ShaderCore.h(875): Reference C2679 : or       'FArchive &operator <<(FArchive &,FShaderDiagnosticData &)' [found using argument-dependent lookup]
11>VertexFactory.h(485): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVertexFactoryType *&)' [found using argument-dependent lookup]
11>PhysicsInterfaceWrapperShared.h(58): Reference C2679 : or       'FArchive &operator <<(FArchive &,FQueryFlags &)' [found using argument-dependent lookup]
11>PhysicsInterfaceWrapperShared.h(116): Reference C2679 : or       'FArchive &operator <<(FArchive &,FHitFlags &)' [found using argument-dependent lookup]
11>CollisionFilterData.h(49): Reference C2679 : or       'Chaos::FChaosArchive &operator <<(Chaos::FChaosArchive &,FCollisionFilterData &)' [found using argument-dependent lookup]
11>EdGraphPin.h(66): Reference C2679 : or       'FArchive &operator <<(FArchive &,FSimpleMemberReference &)' [found using argument-dependent lookup]
11>AnimCurveTypes.h(1223): Reference C2679 : or       'FArchive &operator <<(FArchive &,FRawCurveTracks &)' [found using argument-dependent lookup]
11>AnimCompressionTypes.h(140): Reference C2679 : or       'FArchive &operator <<(FArchive &,FAnimationErrorStats &)' [found using argument-dependent lookup]
11>AnimCompressionTypes.h(174): Reference C2679 : or       'FArchive &operator <<(FArchive &,FCompressedOffsetData &)' [found using argument-dependent lookup]
11>Interface_CollisionDataProviderCore.h(23): Reference C2679 : or       'void operator <<(FArchive &,FTriIndices &)' [found using argument-dependent lookup]
11>Interface_CollisionDataProviderCore.h(63): Reference C2679 : or       'void operator <<(FArchive &,FTriMeshCollisionData &)' [found using argument-dependent lookup]
11>CompressedBuffer.h(176): Reference C2679 : or       'FArchive &operator <<(FArchive &,FCompressedBuffer &)' [found using argument-dependent lookup]
11>RHIUniformBufferLayoutInitializer.h(30): Reference C2679 : or       'FArchive &operator <<(FArchive &,FRHIUniformBufferResourceInitializer &)' [found using argument-dependent lookup]
11>MaterialShared.h(2913): Reference C2679 : or       'FArchive &operator <<(FArchive &,FMaterialResourceLocOnDisk &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(376): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogDevice::FVisualLogEntryItem &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(377): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogDataBlock &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(378): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogHistogramSample &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(379): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogShapeElement &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(380): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogEvent &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(381): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogLine &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(382): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogStatusCategory &)' [found using argument-dependent lookup]
11>VisualLoggerTypes.h(383): Reference C2679 : or       'FArchive &operator <<(FArchive &,FVisualLogEntry &)' [found using argument-dependent lookup]
11>Archive.h(1202): Reference C2679 : or       'FArchive &FArchive::operator <<(TCheckedObjPtr<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &FArchive::operator <<(TCheckedObjPtr<T> &)': could not deduce template argument for 'TCheckedObjPtr<T> &' from 'UBlock *'
11>Archive.h(2270): Reference C2679 : or       'FArchive &operator <<(FArchive &,EnumType &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,EnumType &)': could not deduce template argument for '__formal'
11>Archive.h(2268): Reference C2679 : 'std::enable_if_t<false,int>' : Failed to specialize alias template
11>Archive.h(2249): Reference C2679 : or       'FArchive &operator <<(FArchive &,TEnumAsByte<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TEnumAsByte<T> &)': could not deduce template argument for 'TEnumAsByte<T> &' from 'UBlock *'
11>Archive.h(2249): Reference C2679 : or       'FArchive &operator <<(FArchive &,TEnumAsByte<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TEnumAsByte<T> &)': could not deduce template argument for 'TEnumAsByte<T> &' from 'UBlock *'
11>Archive.h(2270): Reference C2679 : or       'FArchive &operator <<(FArchive &,EnumType &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,EnumType &)': could not deduce template argument for '__formal'
11>Archive.h(2268): Reference C2679 : 'std::enable_if_t<false,int>' : Failed to specialize alias template
11>Array.h(3784): Reference C2679 : or       'FArchive &operator <<(FArchive &,TArray<T,AllocatorType> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TArray<T,AllocatorType> &)': could not deduce template argument for 'TArray<T,AllocatorType> &' from 'UBlock *'
11>BitArray.h(2226): Reference C2679 : or       'FArchive &operator <<(FArchive &,TBitArray<AllocatorA> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TBitArray<AllocatorA> &)': could not deduce template argument for 'TBitArray<AllocatorA> &' from 'UBlock *'
11>Optional.h(414): Reference C2679 : or       'FArchive &operator <<(FArchive &,TOptional<OptionalType> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TOptional<OptionalType> &)': could not deduce template argument for 'TOptional<OptionalType> &' from 'UBlock *'
11>StructuredArchiveSlots.h(217): Reference C2679 : or       'void operator <<(FStructuredArchiveSlot,TArray<T,FDefaultAllocator> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchiveSlot,TArray<T,FDefaultAllocator> &)': could not deduce template argument for 'TArray<T,FDefaultAllocator> &' from 'UBlock *'
11>UniqueObj.h(71): Reference C2679 : or       'FArchive &operator <<(FArchive &,TUniqueObj<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TUniqueObj<T> &)': could not deduce template argument for 'TUniqueObj<T> &' from 'UBlock *'
11>StructuredArchiveAdapters.h(125): Reference C2679 : or       'FArchive &operator <<(FArchive &,T &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,T &)': could not deduce template argument for '__formal'
11>StructuredArchiveAdapters.h(124): Reference C2679 : 'std::enable_if_t<false,int>' : Failed to specialize alias template
11>StructuredArchiveAdapters.h(140): Reference C2679 : or       'void operator <<(FStructuredArchiveSlot,T &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchiveSlot,T &)': could not deduce template argument for '__formal'
11>StructuredArchiveAdapters.h(139): Reference C2679 : 'std::enable_if_t<false,int>' : Failed to specialize alias template
11>SparseArray.h(1483): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSparseArray<T,Allocator> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSparseArray<T,Allocator> &)': could not deduce template argument for 'TSparseArray<T,Allocator> &' from 'UBlock *'
11>SparseArray.h(1512): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot,TSparseArray<T,Allocator> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot,TSparseArray<T,Allocator> &)': could not deduce template argument for 'TSparseArray<T,Allocator> &' from 'UBlock *'
11>Set.h(2244): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSetElement<InElementType> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSetElement<InElementType> &)': could not deduce template argument for 'TSetElement<InElementType> &' from 'UBlock *'
11>Set.h(2251): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot &,TSetElement<InElementType> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot &,TSetElement<InElementType> &)': could not deduce template argument for 'TSetElement<InElementType> &' from 'UBlock *'
11>Set.h(2258): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSet<InElementType,KeyFuncs,Allocator> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSet<InElementType,KeyFuncs,Allocator> &)': could not deduce template argument for 'TSet<InElementType,KeyFuncs,Allocator> &' from 'UBlock *'
11>Set.h(2265): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot &,TSet<InElementType,KeyFuncs,Allocator> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot &,TSet<InElementType,KeyFuncs,Allocator> &)': could not deduce template argument for 'TSet<InElementType,KeyFuncs,Allocator> &' from 'UBlock *'
11>Tuple.h(986): Reference C2679 : or       'FArchive &operator <<(FArchive &,TTuple<ElementTypes...> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TTuple<ElementTypes...> &)': could not deduce template argument for 'TTuple<ElementTypes...> &' from 'UBlock *'
11>Tuple.h(993): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot,TTuple<ElementTypes...> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot,TTuple<ElementTypes...> &)': could not deduce template argument for 'TTuple<ElementTypes...> &' from 'UBlock *'
11>Map.h(1991): Reference C2679 : or       'FArchive &operator <<(FArchive &,TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs> &)': could not deduce template argument for 'TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs> &' from 'UBlock *'
11>Map.h(1998): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot,TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot,TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs> &)': could not deduce template argument for 'TMapBase<KeyType,ValueType,SetAllocator,KeyFuncs> &' from 'UBlock *'
11>StringBuilder.h(445): Reference C2679 : or       'unknown-type operator <<(TStringBuilderBase<CharType> &,CharRangeType &&)'
11>Array.h(3763): Reference C2679 : 'unknown-type operator <<(TStringBuilderBase<CharType> &,CharRangeType &&)': could not deduce template argument for 'TStringBuilderBase<CharType> &' from 'FArchive'
11>StringBuilder.h(478): Reference C2679 : or       'FAnsiStringBuilderBase &operator <<(FAnsiStringBuilderBase &,T)'
11>Array.h(3763): Reference C2679 : 'initializing': cannot convert from 'FArchive' to 'FAnsiStringBuilderBase &'
11>StringBuilder.h(480): Reference C2679 : or       'FWideStringBuilderBase &operator <<(FWideStringBuilderBase &,T)'
11>Array.h(3763): Reference C2679 : 'initializing': cannot convert from 'FArchive' to 'FWideStringBuilderBase &'
11>StringBuilder.h(482): Reference C2679 : or       'FUtf8StringBuilderBase &operator <<(FUtf8StringBuilderBase &,T)'
11>Array.h(3763): Reference C2679 : 'initializing': cannot convert from 'FArchive' to 'FUtf8StringBuilderBase &'
11>StringBuilder.h(514): Reference C2679 : or       'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const T &)'
11>Array.h(3763): Reference C2679 : 'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const T &)': could not deduce template argument for 'TStringBuilderBase<CharType> &' from 'FArchive'
11>WeakObjectPtrTemplates.h(385): Reference C2679 : or       'FArchive &operator <<(FArchive &,TWeakObjectPtr<T,TWeakObjectPtrBase> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TWeakObjectPtr<T,TWeakObjectPtrBase> &)': could not deduce template argument for 'TWeakObjectPtr<T,TWeakObjectPtrBase> &' from 'UBlock *'
11>IndirectArray.h(448): Reference C2679 : or       'FArchive &operator <<(FArchive &,TIndirectArray<T,Allocator> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TIndirectArray<T,Allocator> &)': could not deduce template argument for 'TIndirectArray<T,Allocator> &' from 'UBlock *'
11>RefCounting.h(502): Reference C2679 : or       'FArchive &operator <<(FArchive &,TRefCountPtr<ReferencedType> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TRefCountPtr<ReferencedType> &)': could not deduce template argument for 'TRefCountPtr<ReferencedType> &' from 'UBlock *'
11>Guid.h(423): Reference C2679 : or       'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const FGuid &)'
11>Array.h(3763): Reference C2679 : 'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const FGuid &)': could not deduce template argument for 'TStringBuilderBase<CharType> &' from 'FArchive'
11>SortedMap.h(854): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSortedMap<InKeyType,InValueType,ArrayAllocator,SortPredicate> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSortedMap<InKeyType,InValueType,ArrayAllocator,SortPredicate> &)': could not deduce template argument for 'TSortedMap<InKeyType,InValueType,ArrayAllocator,SortPredicate> &' from 'UBlock *'
11>TVariant.h(222): Reference C2679 : or       'FArchive &operator <<(UE::Core::Private::TAlwaysFArchive<TVariant<Ts...>>::Type &,TVariant<Ts...> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(UE::Core::Private::TAlwaysFArchive<TVariant<Ts...>>::Type &,TVariant<Ts...> &)': could not deduce template argument for 'TVariant<Ts...> &' from 'UBlock *'
11>DynamicRHIResourceArray.h(148): Reference C2679 : or       'FArchive &operator <<(FArchive &,TResourceArray<ElementType,Alignment> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TResourceArray<ElementType,Alignment> &)': could not deduce template argument for 'TResourceArray<ElementType,Alignment> &' from 'UBlock *'
11>StaticArray.h(219): Reference C2679 : or       'FArchive &operator <<(FArchive &,TStaticArray<InElementType,NumElements,Alignment> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TStaticArray<InElementType,NumElements,Alignment> &)': could not deduce template argument for 'TStaticArray<InElementType,NumElements,Alignment> &' from 'UBlock *'
11>ObjectPtr.h(793): Reference C2679 : or       'FArchive &operator <<(FArchive &,TObjectPtr<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TObjectPtr<T> &)': could not deduce template argument for 'TObjectPtr<T> &' from 'UBlock *'
11>ObjectPtr.h(799): Reference C2679 : or       'void operator <<(FStructuredArchiveSlot,TObjectPtr<T> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchiveSlot,TObjectPtr<T> &)': could not deduce template argument for 'TObjectPtr<T> &' from 'UBlock *'
11>LazyObjectPtr.h(374): Reference C2679 : or       'FArchive &operator <<(FArchive &,TLazyObjectPtr<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TLazyObjectPtr<T> &)': could not deduce template argument for 'TLazyObjectPtr<T> &' from 'UBlock *'
11>SoftObjectPtr.h(416): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSoftObjectPtr<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSoftObjectPtr<T> &)': could not deduce template argument for 'TSoftObjectPtr<T> &' from 'UBlock *'
11>SoftObjectPtr.h(749): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSoftClassPtr<TClass> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSoftClassPtr<TClass> &)': could not deduce template argument for 'TSoftClassPtr<TClass> &' from 'UBlock *'
11>SubclassOf.h(192): Reference C2679 : or       'FArchive &operator <<(FArchive &,TSubclassOf<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TSubclassOf<T> &)': could not deduce template argument for 'TSubclassOf<T> &' from 'UBlock *'
11>SubclassOf.h(199): Reference C2679 : or       'void operator <<(FStructuredArchiveSlot,TSubclassOf<T> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchiveSlot,TSubclassOf<T> &)': could not deduce template argument for 'TSubclassOf<T> &' from 'UBlock *'
11>Blake3.h(174): Reference C2679 : or       'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const FBlake3Hash &)'
11>Array.h(3763): Reference C2679 : 'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const FBlake3Hash &)': could not deduce template argument for 'TStringBuilderBase<CharType> &' from 'FArchive'
11>IoHash.h(172): Reference C2679 : or       'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const FIoHash &)'
11>Array.h(3763): Reference C2679 : 'TStringBuilderBase<CharType> &operator <<(TStringBuilderBase<CharType> &,const FIoHash &)': could not deduce template argument for 'TStringBuilderBase<CharType> &' from 'FArchive'
11>StructOnScope.h(381): Reference C2679 : or       'FArchive &operator <<(FArchive &,TStructOnScope<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TStructOnScope<T> &)': could not deduce template argument for 'TStructOnScope<T> &' from 'UBlock *'
11>PerPlatformProperties.h(203): Reference C2679 : or       'FArchive &operator <<(FArchive &,TPerPlatformProperty<_StructType,_ValueType,_BasePropertyName> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TPerPlatformProperty<_StructType,_ValueType,_BasePropertyName> &)': could not deduce template argument for 'TPerPlatformProperty<_StructType,_ValueType,_BasePropertyName> &' from 'UBlock *'
11>PerPlatformProperties.h(205): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot,TPerPlatformProperty<_StructType,_ValueType,_BasePropertyName> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot,TPerPlatformProperty<_StructType,_ValueType,_BasePropertyName> &)': could not deduce template argument for 'TPerPlatformProperty<_StructType,_ValueType,_BasePropertyName> &' from 'UBlock *'
11>PerQualityLevelProperties.h(179): Reference C2679 : or       'FArchive &operator <<(FArchive &,FPerQualityLevelProperty<_StructType,_ValueType,_BasePropertyName> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,FPerQualityLevelProperty<_StructType,_ValueType,_BasePropertyName> &)': could not deduce template argument for 'FPerQualityLevelProperty<_StructType,_ValueType,_BasePropertyName> &' from 'UBlock *'
11>PerQualityLevelProperties.h(182): Reference C2679 : or       'void operator <<(FStructuredArchive::FSlot,FPerQualityLevelProperty<_StructType,_ValueType,_BasePropertyName> &)'
11>Array.h(3763): Reference C2679 : 'void operator <<(FStructuredArchive::FSlot,FPerQualityLevelProperty<_StructType,_ValueType,_BasePropertyName> &)': could not deduce template argument for 'FPerQualityLevelProperty<_StructType,_ValueType,_BasePropertyName> &' from 'UBlock *'
11>MeshAttributeArray.h(90): Reference C2679 : or       'TEnableIf<!TIsBulkSerializable<T>::Value,FArchive>::Type &operator <<(FArchive &,TMeshAttributeArrayBase<AttributeType> &)'
11>Array.h(3763): Reference C2679 : 'TEnableIf<!TIsBulkSerializable<T>::Value,FArchive>::Type &operator <<(FArchive &,TMeshAttributeArrayBase<AttributeType> &)': could not deduce template argument for 'TMeshAttributeArrayBase<AttributeType> &' from 'UBlock *'
11>MeshAttributeArray.h(91): Reference C2679 : or       'TEnableIf<TIsBulkSerializable<T>::Value,FArchive>::Type &operator <<(FArchive &,TMeshAttributeArrayBase<AttributeType> &)'
11>Array.h(3763): Reference C2679 : 'TEnableIf<TIsBulkSerializable<T>::Value,FArchive>::Type &operator <<(FArchive &,TMeshAttributeArrayBase<AttributeType> &)': could not deduce template argument for 'TMeshAttributeArrayBase<AttributeType> &' from 'UBlock *'
11>WeakFieldPtr.h(354): Reference C2679 : or       'FArchive &operator <<(FArchive &,TWeakFieldPtr<T> &)'
11>Array.h(3763): Reference C2679 : 'FArchive &operator <<(FArchive &,TWeakFieldPtr<T> &)': could not deduce template argument for 'TWeakFieldPtr<T> &' from 'UBlock *'
11>Array.h(3763): Reference C2679 : while trying to match the argument list '(FArchive, UBlock *)'
11>Array.h(3763): Reference C2679 : the template instantiation context (the oldest one first) is
11>BlockArray3D.cpp(45): Reference C2679 : see reference to function template instantiation 'FArchive &operator <<<UBlock*,FDefaultAllocator>(FArchive &,TArray<UBlock *,FDefaultAllocator> &)' being compiled
11>Array.h(3786): Reference C2679 : see reference to function template instantiation 'FArchive &TArrayPrivateFriend::Serialize<UBlock*,FDefaultAllocator>(FArchive &,TArray<UBlock *,FDefaultAllocator> &)' being compiled

This is the simplified code for UBlockArray3D:

UCLASS()
class VOXELGAME_API UBlockArray3D : public UObject
{
	GENERATED_BODY()

public:
	UBlockArray3D()
	{
	}

	UPROPERTY()
	TArray<UBlock*> Array;

	// ....

private:
	UPROPERTY()
	int FilledCounter = 0;

	virtual void Serialize(FArchive& Ar) override;
};
// ...

void UBlockArray3D::Serialize(FArchive& Ar)
{
	Ar << Array;
	Ar << FilledCounter;
}

And for UBlock:

UCLASS()
class VOXELGAME_API UBlock : public UObject
{
	GENERATED_BODY()

public:
	friend FArchive& operator<<(FArchive& Ar, UBlock& Block)
	{
		Block.Serialize(Ar);
		return Ar;
	}

	virtual void Serialize(FArchive& Ar) override
	{
		// TODO
	};
};

inline FArchive& operator<<(FArchive& Ar, UBlock* Block)
{
	if (Block)
	{
		Block->Serialize(Ar);
	}
	return Ar;
}

So, for anyone here in the future, serializing a UObject is a little trickier, basically you have two options: create a struct with the data of your UObject, or customize the Serialize function to handle the UObject creation/copy

With structs

Just create a Struct with all the data you want to serialize/desserialize, then do something like this:

USTRUCT(BlueprintType)
struct FBlockData
{
	GENERATED_BODY()

	FBlockData()
	{
	}

	FBlockData(TSubclassOf<UBlock> InBlockType)
	{
		BlockType = InBlockType;
	}

	UPROPERTY()
	TSubclassOf<UBlock> BlockType = UBlock::StaticClass();

	void Serialize(FArchive& Ar)
	{
		Ar << BlockType;
	}
};

FORCEINLINE FArchive& operator<<(FArchive& Ar, FBlockData& BlockData)
{
	BlockData.Serialize(Ar);
	return Ar;
}

Custom Serialize

As the pointers of the objects only make senses in the context of the game, and they also are deleted when the game closes, we have to gatter all the important data from the object then save it to Archive, and for the deserialization we initialize a new object then insert the data from the Archive:

void UChunks::Serialize(FArchive& Ar)
{
	if (Ar.IsSaving())
	{
		int32 Objects = ChunksData.Num();
		Ar << Objects;

        // In my case ChunksData is a TMap<FVector2D, UBlockArray3D*>
		for (auto& Pair : ChunksData)
		{
			Ar << Pair.Key;
			Pair.Value->Serialize(Ar);
		}
	}
	else if (Ar.IsLoading())
	{
		int32 Objects = 0;
		Ar << Objects;

		for (int i = 0; i < Objects; i++)
		{
			FVector2D Key;
			Ar << Key;

			UBlockArray3D* Value = NewObject<UBlockArray3D>(this);
			Ar << Value;

			ChunksData.Add(Key, Value);
		}
	}
}

Extra
I know there is a FObjectAndNameAsStringProxyArchive which allow to serialize TSubclassOf objects easily, I haven’t tested if it handles the serialization/deserialization of UObjects too.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.