Struct GhostComponentSerializer.State
This buffer is added to the GhostCollection singleton entity. Stores serialization meta-data for the ghost. Too large to be stored in chunk memory. Values are generated by the Source Generators.
Inherited Members
Namespace: Unity.NetCode.LowLevel.Unsafe
Syntax
[InternalBufferCapacity(0)]
public struct State : IBufferElementData
Fields
ChangeMaskBits
The number of bits necessary for the change mask.
Declaration
public int ChangeMaskBits
Field Value
| Type | Description |
|---|---|
| Int32 |
ComponentSize
The size of the component, as reported by the TypeManager.
Declaration
public int ComponentSize
Field Value
| Type | Description |
|---|---|
| Int32 |
ComponentType
The type of component this serializer act on.
Declaration
public ComponentType ComponentType
Field Value
| Type | Description |
|---|---|
| ComponentType |
CopyFromSnapshot
Delegate method used to transfer data from the snapshot buffer to the destination component.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> CopyFromSnapshot
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> |
CopyToSnapshot
Delegate method used to transfer the component data to the snapshot buffer.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> CopyToSnapshot
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.CopyToFromSnapshotDelegate> |
Deserialize
Deserialize the component and buffer data from the received snapshot and store it inside the SnapshotDataBuffer.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.DeserializeDelegate> Deserialize
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.DeserializeDelegate> |
GhostFieldsHash
The hash of all serializer fields, along with their GhostFieldAttribute options properties. Used to calculate the NetworkProtocolVersion.
Declaration
public ulong GhostFieldsHash
Field Value
| Type | Description |
|---|---|
| UInt64 |
PostSerialize
Delegate method to use to post-serialize the component when the ghost use pre-serialization optimization.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.PostSerializeDelegate> PostSerialize
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.PostSerializeDelegate> |
PostSerializeBuffer
Delegate method to use to post-serialize buffers when the ghost use pre-serialization optimization.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.PostSerializeBufferDelegate> PostSerializeBuffer
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.PostSerializeBufferDelegate> |
PredictDelta
Calculate the prediction delta for components and buffer. Used for delta-compression.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.PredictDeltaDelegate> PredictDelta
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.PredictDeltaDelegate> |
PrefabType
Store the PrefabType if the attribute is present on the component. Otherwise is set to All. TODO - Try to deduplicate this data by reading the ComponentTypeSerializationStrategy directly.
Declaration
public GhostPrefabType PrefabType
Field Value
| Type | Description |
|---|---|
| GhostPrefabType |
RestoreFromBackup
Delegate method used to restore the state of a replicated component from the Unity.NetCode.GhostPredictionHistoryState buffer. Because the history buffer perform a memory copy of the whole component data, it is necessary to call this method to ensure only the replicated portion of the component is actually restored.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.RestoreFromBackupDelegate> RestoreFromBackup
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.RestoreFromBackupDelegate> |
SendMask
Indicates for which type of ghosts the component should be replicated. The mask is set by code-gen base on the PrefabType constraint.
Declaration
public GhostComponentSerializer.SendMask SendMask
Field Value
| Type | Description |
|---|---|
| GhostComponentSerializer.SendMask |
SendToOwner
Store the OwnerSendType if the attribute is present on the component. Otherwise is set to All.
Declaration
public SendToOwnerType SendToOwner
Field Value
| Type | Description |
|---|---|
| SendToOwnerType |
SerializationStrategyIndex
Internal. Indexer into the Unity.NetCode.GhostComponentSerializerCollectionData.SerializationStrategies list.
Declaration
public short SerializationStrategyIndex
Field Value
| Type | Description |
|---|---|
| Int16 |
Serialize
Delegate method used to serialize the component data for the root entity into the outgoing data stream. Work in batch.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.SerializeDelegate> Serialize
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.SerializeDelegate> |
SerializeBuffer
Delegate method used to serialize the buffer content for the whole chunk. Work in batch for the whole chunk.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.SerializeBufferDelegate> SerializeBuffer
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.SerializeBufferDelegate> |
SerializeChild
Delegate method used to serialize the component data present in the child entity into the outgoing data stream. Work on a single entity at time.
Declaration
public PortableFunctionPointer<GhostComponentSerializer.SerializeChildDelegate> SerializeChild
Field Value
| Type | Description |
|---|---|
| PortableFunctionPointer<GhostComponentSerializer.SerializeChildDelegate> |
SerializerHash
An unique hash computed by source generator that identify the serializer type.
Declaration
public ulong SerializerHash
Field Value
| Type | Description |
|---|---|
| UInt64 |
SerializesEnabledBit
True if this component has the GhostEnabledBitAttribute and thus should replicate the enable bit flag.
Declaration
public byte SerializesEnabledBit
Field Value
| Type | Description |
|---|---|
| Byte |
Remarks
Note that serializing the enabled bit is different from the main "serializer". I.e. "Empty Variants" can have serialized enable bits.
SnapshotSize
The size of the component inside the snapshot buffer.
Declaration
public int SnapshotSize
Field Value
| Type | Description |
|---|---|
| Int32 |
VariantHash
An hash identifying the specific variation used for this serializer (see GhostComponentVariationAttribute).
If no variation is used, this will be the hash of the ComponentType itself, and
Declaration
public ulong VariantHash
Field Value
| Type | Description |
|---|---|
| UInt64 |
Properties
HasGhostFields
Whether SnapshotSize is greater than zero.
Declaration
public readonly bool HasGhostFields { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |