Can FFastNetArraySerializer be nested another USTRUCT?

I wonder if this is possible, that it works as I expected.



USTRUCT()
struct FGameItemInstanceNetArrayArg : public FFastArraySerializerItem
{
    UPROPERTY()
    TSubclassOf<UItem> ItemClass;
    UPROPERTY()
    int32 InventorySlotId;
    UPROPERTY()
    TArray<uint8> RawItemTraits;
...
};

struct FGameItemInstanceNetArray : public FFastArraySerializer


However, an argument class FGameItemInstanceNetArrayArg can be pretty complex since it can hold an item’s unique traits; creator, color, durability, etc …

For now, I manage those traits as ‘ItemTrait’ class, which derives UObject class, which cannot be replicated as is. Thus when It needs to be serialized to the client, it firstly serialized into TArray, and replicated. Of course, as you see, those are extremely inefficient. Even a single change of a trait element causes re-serialization and replication of whole byte array. And I cannot make trait class as concrete USTRUCT, because there will be lots of variance of item traits.

Therefore I’m planning to change item traits into the map of key-byte chunks, like below.



USTRUCT()
struct FGameItemTraitArg : public FFastArraySerializerItem
{
   UPROPERTY()
   uint32 KeyHash;           // Will get from GetTypeHash() function
   UPROPERTY()
   uint8 Chunk[28];           // Can hold any item ... maximum of 28 bytes of data ...  
};

USTRUCT()
struct FGameItemTraitNetMap : public FFastArraySerializer
{ ... } // Uses FGameItemTraitArg as serializer item ...

USTRUCT()
struct FGameItemInstanceNetArrayArg : public FFastArraySerializerItem
{
    UPROPERTY()
    TSubclassOf<UItem> ItemClass;
    UPROPERTY()
    int32 InventorySlotId;
    UPROPERTY()
    FGameItemTraitNetMap Traits;
;
...
}


I wonder if this is possible, that it works as I expected; optimizes array serialization like working as UCLASS’s property

1 Like

@anonymous_user_00c7dad7

Did you manage to get a solution for this? I have a similar problem in terms of how should I nest arrays for fast serialization.

To answer the original question, no they cannot be nested.