docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct GhostImportance

    Singleton component used to control importance scaling (also called priority scaling) settings on the server. Used by the GhostSendSystem to help it prioritize which ghost chunks to write into each snapshot sent to each individual connection. I.e. Importance scaling is applied on a per-connection basis. Create this singleton in a server-only, user-code system to enable this feature. Further reading: https://docs.unity3d.com/Packages/com.unity.netcode@latest/index.html?subfolder=/manual/optimizations.html#importance-scaling

    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
    [BurstCompile]
    public struct GhostImportance : IComponentData, IQueryTypeParameter
    Remarks

    The most common use-case of importance scaling is "distance importance scaling". I.e. To send updates for nearby ghosts at a significantly higher frequency than for far away ghosts. Our default implementation (GhostDistanceImportance) does exactly that.

    Fields

    BatchScaleImportanceFunction

    This function pointer will be invoked with collected data as described in GhostImportance.BatchScaleImportanceDelegate.

    It is mandatory to set either this or ScaleImportanceFunction function pointer. It is also valid to set both, in which case the BatchScaleImportanceFunction is preferred.

    Declaration
    public PortableFunctionPointer<GhostImportance.BatchScaleImportanceDelegate> BatchScaleImportanceFunction
    Field Value
    Type Description
    PortableFunctionPointer<GhostImportance.BatchScaleImportanceDelegate>

    GhostConnectionComponentType

    ComponentType for connection data. GhostSendSystem will query for this component type before invoking the function assigned to BatchScaleImportanceFunction.

    Declaration
    public ComponentType GhostConnectionComponentType
    Field Value
    Type Description
    ComponentType

    GhostImportanceDataType

    Optional singleton ComponentType for configuration data. Leave default if not required. Zero will be passed into the BatchScaleImportanceFunction. GhostSendSystem will query for this component type, passing the data into the BatchScaleImportanceFunction function when invoking it.

    Declaration
    public ComponentType GhostImportanceDataType
    Field Value
    Type Description
    ComponentType

    GhostImportancePerChunkDataType

    ComponentType for per chunk data. Must be a shared component type! Each chunk represents a group of entities, collected as they share some importance-related value (e.g. distance to the players character controller). GhostSendSystem will query for this component type before invoking the function assigned to BatchScaleImportanceFunction.

    Declaration
    public ComponentType GhostImportancePerChunkDataType
    Field Value
    Type Description
    ComponentType
    Remarks

    Tip: You can use the existence of this type to filter/decide which ghost chunks should even undergo importance scaling by the GhostSendSystem. To exclude a type from importance scaling, do not add this shared component to their chunk.

    NoScaleFunctionPointer

    Default implementation of GhostImportance.ScaleImportanceDelegate. Will return basePriority without computation.

    Declaration
    public static readonly PortableFunctionPointer<GhostImportance.ScaleImportanceDelegate> NoScaleFunctionPointer
    Field Value
    Type Description
    PortableFunctionPointer<GhostImportance.ScaleImportanceDelegate>

    ScaleImportanceFunction

    This function pointer will be invoked with collected data as described in GhostImportance.BatchScaleImportanceDelegate.

    It is mandatory to set either this or BatchScaleImportanceFunction function pointer. It is also valid to set both, in which case the BatchScaleImportanceFunction is preferred.

    Declaration
    public PortableFunctionPointer<GhostImportance.ScaleImportanceDelegate> ScaleImportanceFunction
    Field Value
    Type Description
    PortableFunctionPointer<GhostImportance.ScaleImportanceDelegate>

    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)