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, INetworkSerializable

Inherits: FactorableData Implements: Unity.Netcode.INetworkSerializable

Remarks

NetworkFactorableData serves as the base record for all data used by NetworkScriptableFactory<TObject, TData>arrow-up-right. 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

Goal
How

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.

Parameter
Type
Description

serializer

BufferSerializer<T>

Netcode buffer serializer — reads or writes depending on context

circle-info

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

Method
Purpose

NetworkSerialize<T>()

Define binary layout for all data fields that must travel over the network

Implementation Requirements

When subclassing NetworkFactorableData, you MUST:

  1. Override NetworkSerialize<T>() and serialize every field that needs to be replicated

  2. Use serializer.SerializeValue(ref field) for each serializable field

  3. Mark 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 overrides

  • Match 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. Use NetworkObjectReference or lookup hashes instead

  • Skip fields in NetworkSerialize<T>() — partial serialization causes deserialization to read the wrong bytes for subsequent fields

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Basic data record

Data with complex fields

See Also

Last updated