NetworkFactorableData
Abstract record that extends FactorableData with INetworkSerializable, enabling factory data to be serialized and transmitted over the network via Unity Netcode. Subclasses must implement NetworkSerialize<T>() to define their binary serialization format.
Definition
Namespace: Paragon.Core.Network
Assembly: Paragon.dll
public abstract record NetworkFactorableData : FactorableData, INetworkSerializableInherits: FactorableData
Implements: Unity.Netcode.INetworkSerializable
Remarks
NetworkFactorableData serves as the base record for all data used by NetworkScriptableFactory<TObject, TData>. By combining FactorableData (which provides variant system compatibility, copy support, and Inspector serialization) with INetworkSerializable (which provides binary network serialization), this record enables data-driven factories to transmit spawn data to remote clients.
Because this is a record type (not a class), it inherits value-based equality and with-expression copy semantics from FactorableData. The NetworkSerialize<T>() method is the only addition — all other data fields and behaviors come from the concrete subclass.
Quick Lookup
Create network-serializable data
Subclass NetworkFactorableData, override NetworkSerialize<T>()
Use with a factory
Constrain factory with TData : NetworkFactorableData
Serialize a field
serializer.SerializeValue(ref field) inside NetworkSerialize<T>()
Methods
NetworkSerialize<T>
Serializes or deserializes this data record for network transmission.
serializer
BufferSerializer<T>
Netcode buffer serializer — reads or writes depending on context
BufferSerializer<T> handles both serialization and deserialization through the same method. Use serializer.SerializeValue(ref field) for each field — it reads or writes based on whether T is a reader or writer.
Extension Points
Required Overrides
NetworkSerialize<T>()
Define binary layout for all data fields that must travel over the network
Implementation Requirements
When subclassing NetworkFactorableData, you MUST:
Override
NetworkSerialize<T>()and serialize every field that needs to be replicatedUse
serializer.SerializeValue(ref field)for each serializable fieldMark the record with
[Serializable]for Unity/Odin Inspector serialization
You SHOULD:
Keep serialized data minimal — only include fields needed by remote clients
Use
[Overridable]attribute on fields that should support variant overridesMatch serialization order exactly between server and client (field order matters)
You SHOULD NOT:
Serialize Unity object references (
GameObject,Transform, etc.) — these are not network-serializable. UseNetworkObjectReferenceor lookup hashes insteadSkip fields in
NetworkSerialize<T>()— partial serialization causes deserialization to read the wrong bytes for subsequent fields
Common Pitfalls
Serialization order must be consistent
Fields must be serialized in the same order on both server and client. If you add a new field, append it to the end of NetworkSerialize<T>() to maintain backward compatibility during development.
Non-serializable types
Unity object references (GameObject, MonoBehaviour, ScriptableObject) cannot be serialized via INetworkSerializable. Use integer IDs, hashes, or NetworkObjectReference to reference networked objects.
Record copy semantics
When FactorableDataUtility.CreateCopy() creates a deep copy, the NetworkSerialize<T>() method is not involved — copying uses Odin binary serialization. Ensure all fields are properly serializable by both systems.
Examples
Basic data record
Data with complex fields
See Also
FactorableData — base record class
NetworkScriptableFactory<TObject, TData> — data-aware network factory
OverridableAttribute — marks fields for variant overrides
DataVariantSystem — variant system that produces data copies
Last updated