docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostCollection

    A component used to identify the singleton which owns the ghost collection lists and data. The singleton contains buffers for GhostCollectionPrefab, GhostCollectionPrefabSerializer, GhostCollectionComponentIndex and GhostComponentSerializer.State

    Implements
    IComponentData
    IQueryTypeParameter
    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
    public struct GhostCollection : IComponentData, IQueryTypeParameter

    Fields

    GhostTypeToColletionIndex

    The index in the GhostCollectionPrefab list for given GhostType.

    Declaration
    public NativeHashMap<GhostType, int>.ReadOnly GhostTypeToColletionIndex
    Field Value
    Type Description
    NativeHashMap<GhostType, int>.ReadOnly

    IsInGame

    Flag set when there is at least one NetworkStreamConnection that is game.

    Declaration
    public bool IsInGame
    Field Value
    Type Description
    bool

    NumLoadedPrefabs

    The number of prefabs that have been loaded into the GhostCollectionPrefab collection. Use to determine which ghosts types the server can stream to the clients.

    The server reports (to the client) the list of loaded prefabs (with their see GhostTypeComponent guid) as part of the snapshot protocol. The list is dynamic; new prefabs can be added/loaded at runtime (on the server), and the new ones will be reported to the client.

    Clients report (to the server) the number of loaded prefabs, as part of the command protocol. When the client receives a ghost snapshot, the ghost prefab list is processed, and the GhostCollectionPrefab collection is updated with any new ghost types not already present in the collection.

    The client does not need to have loaded ALL prefab types in the GhostCollectionPrefab to initialize the world. I.e. They can be loaded/added dynamically into the world (i.e when streaming a sub-scene), and the Loading state should be used in that case (to inform the GhostCollection that the specified prefabs are currently being loaded into the world).

    Declaration
    public int NumLoadedPrefabs
    Field Value
    Type Description
    int

    PendingGhostPrefabAssignment

    The index in the GhostCollectionPrefab list where the prefab with the given GhostType. It is populated by the GhostReceiveSystem when new prefabs hash are received from the server and it used to track what prefabs need to be mapped/loaded.

    Declaration
    public NativeHashMap<GhostType, int> PendingGhostPrefabAssignment
    Field Value
    Type Description
    NativeHashMap<GhostType, int>
    Remarks

    Should be used only by the client. For server the map is always empty. It also contains a special key for the default(GhostType) that indicate if the list has been changed since the last time has been processed.

    Implements

    Unity.Entities.IComponentData
    Unity.Entities.IQueryTypeParameter
    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)