docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostCollectionPrefabSerializer

    A list of all serializer data for the prefabs in GhostCollectionPrefab. This list can be shorter if not all serializers are created yet. Added to the GhostCollection singleton entity.

    Implements
    IBufferElementData
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    [InternalBufferCapacity(0)]
    public struct GhostCollectionPrefabSerializer : IBufferElementData

    Fields

    BaseImportance

    Higher importance means the ghost will be sent more frequently if there is not enough bandwidth to send everything. Minimum value: 1.

    Declaration
    public int BaseImportance
    Field Value
    Type Description
    int

    ChangeMaskBits

    The number of bits used by change mask bitarray for this entire ghost type.

    Declaration
    public int ChangeMaskBits
    Field Value
    Type Description
    int

    CustomPreSerializer

    The function pointer to invoke for pre-serializing the chunk (only for server).

    Declaration
    public PortableFunctionPointer<GhostPrefabCustomSerializer.ChunkPreserializeDelegate> CustomPreSerializer
    Field Value
    Type Description
    PortableFunctionPointer<GhostPrefabCustomSerializer.ChunkPreserializeDelegate>

    CustomSerializer

    A custom serializer function to serializer the chunk (only for server).

    Declaration
    public PortableFunctionPointer<GhostPrefabCustomSerializer.ChunkSerializerDelegate> CustomSerializer
    Field Value
    Type Description
    PortableFunctionPointer<GhostPrefabCustomSerializer.ChunkSerializerDelegate>

    EnableableBits

    The number of bits necessary to store the enabled state of all the enableable ghost components (that are flagged with GhostEnabledBitAttribute).

    Declaration
    public int EnableableBits
    Field Value
    Type Description
    int

    FallbackPredictionMode

    Used by the GhostSpawnClassificationSystem to assign the type of GhostSpawnBuffer.Type to use for this ghost, if no other user-defined system has classified how the new ghost should be spawned.

    Declaration
    public GhostSpawnBuffer.Type FallbackPredictionMode
    Field Value
    Type Description
    GhostSpawnBuffer.Type

    FirstComponent

    The index of the first component serialization rule to use inside the GhostCollectionComponentIndex.

    Declaration
    public int FirstComponent
    Field Value
    Type Description
    int

    IsGhostGroup

    Flag that indicates if the ghost prefab contains a GhostGroup component and can be used as root of the group.

    Declaration
    public int IsGhostGroup
    Field Value
    Type Description
    int
    See Also
    GhostChildEntity

    MaxBufferSnapshotSize

    The size of the largest replicated Unity.Entities.IBufferElementData for this ghost. It is used to calculate the necessary SnapshotDynamicDataBuffer capacity to hold the replicated buffer data.

    Declaration
    public int MaxBufferSnapshotSize
    Field Value
    Type Description
    int

    MaxSendRateAsSimTickInterval

    MaxSendRate expressed as a SimulationTickRate interval (i.e. the number of ticks until we can send again).

    Declaration
    public byte MaxSendRateAsSimTickInterval
    Field Value
    Type Description
    byte
    See Also
    MaxSendRate

    NumBuffers

    The total number of replicated Unity.Entities.IBufferElementData for this ghost.

    Declaration
    public int NumBuffers
    Field Value
    Type Description
    int

    NumChildComponents

    The total number of serialized components present only in the child entities.

    Declaration
    public int NumChildComponents
    Field Value
    Type Description
    int

    NumComponents

    The total number of serialized components. Include both root and child entities.

    Declaration
    public int NumComponents
    Field Value
    Type Description
    int

    OwnerPredicted

    Flag stating if the ghost replication mode is set to owner predicted.

    Declaration
    public int OwnerPredicted
    Field Value
    Type Description
    int

    PartialComponents

    Set to 1 when the ghost contains components with different GhostComponentSerializer.SendMask. Based on the ghost replication mode (interpolated or predicted), some of these component should be not replicated, and the decision must be made by the GhostSendSystem at runtime, when entities are serialized.

    Declaration
    public byte PartialComponents
    Field Value
    Type Description
    byte

    PartialSendToOwner

    Set to 1 if the ghost has some components for which the OwnerSendType is different than All. When the flag is set, the GhostSendSystem will peform the necessary ghost owner checks.

    Declaration
    public byte PartialSendToOwner
    Field Value
    Type Description
    byte

    PredictedSpawnedGhostRollbackToSpawnTick

    Enable predicted spawned ghost to rollback their initial spawn state and re-predict until the authoritative spawn has been received from the server.

    Declaration
    public byte PredictedSpawnedGhostRollbackToSpawnTick
    Field Value
    Type Description
    byte

    PredictionOwnerOffset

    Only set if the GhostOwner is present on the entity prefab, is the offset in bytes, from the beginning of the snapshot data, in which the network id of the of client owning the entity can be retrieved.

    var ghostOwner = *(uint*)(snapshotDataPtr + PredictionOwnerOffset)
    Declaration
    public int PredictionOwnerOffset
    Field Value
    Type Description
    int

    RollbackPredictionOnStructuralChanges

    Client CPU optimization. Force predicted ghost to always try to continue from the last prediction in case of structural changes. True by default (because may introduce some issue when replicated component are removed).

    Declaration
    public byte RollbackPredictionOnStructuralChanges
    Field Value
    Type Description
    byte

    SnapshotSize

    The total size in bytes of the entire ghost type, including space for enable bits and change masks.

    Declaration
    public int SnapshotSize
    Field Value
    Type Description
    int

    StaticOptimization

    True if the GhostOptimizationMode is set to Static in the GhostAuthoringComponent.

    Declaration
    public byte StaticOptimization
    Field Value
    Type Description
    byte

    TypeHash

    The stable type hash of the prefab. Used to retrieve GhostCollectionPrefabSerializer instance. The hash is composed by the name and the hash of all the component serializers.

    Declaration
    public ulong TypeHash
    Field Value
    Type Description
    ulong

    UseSingleBaseline

    Instruct the GhostSendSystem to always use a single baseline for this ghost archetype.

    Declaration
    public byte UseSingleBaseline
    Field Value
    Type Description
    byte

    profilerMarker

    A profile marker used to track serialization performance.

    Declaration
    public ProfilerMarker profilerMarker
    Field Value
    Type Description
    ProfilerMarker

    Methods

    CanBeStaticOptimized()

    Static-optimization does not support iterating over multiple chunks, which excludes:

    • GhostGroups.
    • Ghosts with replicated children.
    Declaration
    public readonly bool CanBeStaticOptimized()
    Returns
    Type Description
    bool

    true if the entity satisfies the conditions for static optimization.

    Implements

    Unity.Entities.IBufferElementData
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)