docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetCodeConfig

    Config file, allowing the package user to tweak netcode variables without having to write code. Create as many instances as you like.

    Inheritance
    object
    Object
    ScriptableObject
    NetCodeConfig
    Implements
    IComparable<NetCodeConfig>
    Inherited Members
    ScriptableObject.SetDirty()
    ScriptableObject.CreateInstance(string)
    ScriptableObject.CreateInstance(Type)
    ScriptableObject.CreateInstance<T>()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, InstantiateParameters)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.NetCode
    Assembly: Unity.NetCode.dll
    Syntax
    [CreateAssetMenu(menuName = "Multiplayer/NetCodeConfig Asset", fileName = "NetCodeConfig", order = 1)]
    public class NetCodeConfig : ScriptableObject, IComparable<NetCodeConfig>

    Fields

    ClientReceiveQueueCapacity

    Capacity of the receive queue (per pipeline-stage) on the client. This should be the maximum number of in-flight packets expected to be received by the client - from the server - during a worst-case frame (like if the client executable stalls). Broad recommendation: 64.

    Declaration
    [Tooltip("Capacity of the receive queue (per pipeline-stage) on the client.\nThis should be the maximum number of in-flight packets expected to be received by the client - from the\nserver - during a worst-case frame (like if the client executable stalls).\n\nBroad recommendation: 64.\nDefault value: 512 i.e. <b>NetworkParameterConstants.ReceiveQueueCapacity</b>")]
    [Min(8)]
    public int ClientReceiveQueueCapacity
    Field Value
    Type Description
    int
    See Also
    receiveQueueCapacity

    ClientSendQueueCapacity

    Capacity of the send queue (per pipeline-stage) on the client. This should be the maximum number of packets expected to be sent by the client in a single update (i.e. each render frame). Broad recommendation: 8 If not memory constrained, else use minimum, as it can affect Reliable and Fragmentation pipeline throughput.

    Declaration
    [Tooltip("Capacity of the send queue (per pipeline-stage) on the client.\nThis should be the maximum number of packets expected to be sent by the client, per pipeline-stage, in a single update (i.e. each render frame).\n\nRecommended value: 8 if not memory constrained, else minimum, as it can affect Reliable and Fragmentation pipeline throughput.\nDefault value: 512 i.e. <b>NetworkParameterConstants.SendQueueCapacity</b>")]
    [Min(4)]
    public int ClientSendQueueCapacity
    Field Value
    Type Description
    int
    See Also
    sendQueueCapacity

    ClientServerTickRate

    The ClientServerTickRate singleton is used to configure the client and server simulation time step, server packet send rate and other related settings. The singleton entity is automatically created for the clients in the NetworkStreamReceiveSystem first update if not present. On the server, by contrast, the entity is never automatically created and it is up to the user to create the singletong instance if they need to. This behaviour is asymmetric because the client need to have this singleton data synced with the server one. It is like this for compatibility reason and It may be changed in the future. In order to configure these settings you can either:

    • Create the entity in a custom Unity.NetCode.ClientServerBootstrap after the worlds has been created.
    • On a system, in either the OnCreate or OnUpdate.
    It is not mandatory to set all the fields to a proper value when creating the singleton. It is sufficient to change only the relevant setting, and call the ResolveDefaults() method to configure the fields that does not have a value set. The ClientServerTickRate settings are synced as part of the of the initial client connection handshake. (ClientServerTickRateRefreshRequest data). The ClientServerTickRate should also be used to customise other server only timing settings, such as
    • the maximum number of tick per frame
    • the maximum number of tick per frame
    • tick batching (<`MaxSimulationStepBatchSize`) and others.
    See the individual fields documentation for more information.
    Declaration
    public ClientServerTickRate ClientServerTickRate
    Field Value
    Type Description
    ClientServerTickRate

    ClientTickRate

    Create a ClientTickRate singleton in the client world (either at runtime or by loading it from sub-scene) to configure all the network time synchronization, interpolation delay, prediction batching and other setting for the client. See the individual fields for more information about the individual properties.

    Declaration
    public ClientTickRate ClientTickRate
    Field Value
    Type Description
    ClientTickRate

    ConnectTimeoutMS

    Time between connection attempts.

    Declaration
    [Tooltip("Time between connection attempts, in milliseconds.")]
    [Min(1)]
    public int ConnectTimeoutMS
    Field Value
    Type Description
    int

    Timeout in milliseconds.

    DisconnectTimeoutMS

    Inactivity timeout for a connection. If nothing is received on a connection for this amount of time, it is disconnected (a Unity.Networking.Transport.NetworkEvent.Type.Disconnect event will be generated). To prevent this from happenning when the game session is simply quiet, set Unity.Networking.Transport.NetworkConfigParameter.heartbeatTimeoutMS to a positive non-zero value.

    Declaration
    [Tooltip("Inactivity timeout for a connection, in milliseconds. If nothing is received on a connection for this amount of time, it is disconnected (a <b>Disconnect</b> event will be generated).\n\nTo prevent this from happening when the game session is simply quiet, set <b>heartbeatTimeoutMS</b> to a positive non-zero value.")]
    [Min(1)]
    public int DisconnectTimeoutMS
    Field Value
    Type Description
    int

    Timeout in milliseconds.

    EnableClientServerBootstrap

    Denotes if the ClientServerBootstrap (or any derived version of it) should be triggered on game boot. Project-wide setting, overridable via the OverrideAutomaticNetCodeBootstrap MonoBehaviour.

    Declaration
    [Header("NetCode")]
    [Tooltip("Denotes if the ClientServerBootstrap (or any derived version of it) should be triggered on game boot. Project-wide setting (when this config is applied in the Netcode tab), overridable via the OverrideAutomaticNetCodeBootstrap MonoBehaviour.")]
    [SerializeField]
    public NetCodeConfig.AutomaticBootstrapSetting EnableClientServerBootstrap
    Field Value
    Type Description
    NetCodeConfig.AutomaticBootstrapSetting

    GhostSendSystemData

    Singleton entity that contains all the tweakable settings for the GhostSendSystem.

    Declaration
    public GhostSendSystemData GhostSendSystemData
    Field Value
    Type Description
    GhostSendSystemData

    HeartbeatTimeoutMS

    Time after which if nothing from a peer is received, a heartbeat message will be sent to keep the connection alive. Prevents the Unity.Networking.Transport.NetworkConfigParameter.disconnectTimeoutMS mechanism from kicking when nothing happens on a connection. A value of 0 will disable heartbeats.

    Declaration
    [Tooltip("Time after which if nothing from a peer is received, a heartbeat message will be sent to keep the connection alive. Prevents the <b>disconnectTimeoutMS</b> mechanism from kicking when nothing happens on a connection. A value of 0 will disable heartbeats.")]
    [Min(1)]
    public int HeartbeatTimeoutMS
    Field Value
    Type Description
    int

    Timeout in milliseconds.

    IsGlobalConfig

    Netcode helper: Allows you to add multiple configs to the PreloadedAssets list. There can only be one global one.

    Declaration
    public bool IsGlobalConfig
    Field Value
    Type Description
    bool

    MaxConnectAttempts

    Maximum number of connection attempts to try. If no answer is received from the server after this number of attempts, a Unity.Networking.Transport.NetworkEvent.Type.Disconnect event is generated for the connection.

    Declaration
    [Tooltip("Maximum number of connection attempts to try. If no answer is received from the server after this number of attempts, a <b>Disconnect</b> event is generated for the connection.")]
    [Min(1)]
    public int MaxConnectAttempts
    Field Value
    Type Description
    int

    Number of attempts.

    MaxMessageSize

    Maximum size of a packet that can be sent by the transport. Note that this size includes any headers that could be added by the transport (e.g. headers for DTLS or pipelines), which means the actual maximum message size that can be sent by a user is slightly less than this value. To find out what the size of these headers is, use Unity.Networking.Transport.NetworkDriver.MaxHeaderSize(Unity.Networking.Transport.NetworkPipeline). It is possible to send messages larger than that by sending them through a pipeline with a Unity.Networking.Transport.FragmentationPipelineStage. These headers do not include those added by the OS network stack (like UDP or IP).

    Declaration
    [Tooltip("Maximum size of a packet that can be sent by the transport.\n\nNote that this size includes any headers that could be added by the transport (e. g. headers for DTLS or pipelines), which means the actual maximum message size that can be sent by a user is slightly less than this value.\n\nTo find out what the size of these headers is, use MaxHeaderSize(NetworkPipeline).\n\nIt is possible to send messages larger than that by sending them through a pipeline with a FragmentationPipelineStage. These headers do not include those added by the OS network stack (like UDP or IP).")]
    [Range(64, 1472)]
    public int MaxMessageSize
    Field Value
    Type Description
    int

    ReconnectionTimeoutMS

    Time after which to attempt to re-establish a connection if nothing is received from the peer. This is used to re-establish connections for example when a peer's IP address changes (e.g. mobile roaming scenarios). To be effective, should be less than Unity.Networking.Transport.NetworkConfigParameter.disconnectTimeoutMS but greater than Unity.Networking.Transport.NetworkConfigParameter.heartbeatTimeoutMS. A value of 0 will disable this functionality.

    Declaration
    [Tooltip("Time after which to attempt to re-establish a connection if nothing is received from the peer. This is used to re-establish connections for example when a peer's IP address changes (e. g. mobile roaming scenarios).\n\nTo be effective, should be less than <b>disconnectTimeoutMS</b> but greater than <b>heartbeatTimeoutMS</b>.\n\nA value of 0 will disable this functionality.")]
    [Min(1)]
    public int ReconnectionTimeoutMS
    Field Value
    Type Description
    int

    Timeout in milliseconds.

    ServerReceiveQueueCapacity

    Capacity of the receive queue (per pipeline-stage) on the server. This should be the maximum number of in-flight packets - expected to be sent across by the maximum supported number of connected clients - to the server - arriving within a worst-case server game loop update. Broad recommendations: For 2 players, ~64. For 100 players, ~512. For 1k players, ~1.2k.

    Declaration
    [Tooltip("Capacity of the receive queue (per pipeline-stage) on the server.\nThis should be the maximum number of in-flight packets - expected to be sent across by the maximum supported\nnumber of connected clients - to the server - arriving within a worst-case server game loop update.\n\nBroad recommendations: For 2 players, ~64. For 100 players, ~512. For 1k players, ~1.2k.\nDefault value: 512 i.e. <b>NetworkParameterConstants.ReceiveQueueCapacity</b>")]
    [Min(64)]
    public int ServerReceiveQueueCapacity
    Field Value
    Type Description
    int
    See Also
    receiveQueueCapacity

    ServerSendQueueCapacity

    Capacity of the send queue (per pipeline-stage) on the server. This should be a multiple (likely 1) of the maximum number of packets expected to be sent by the server, across all connections, on a per pipeline-stage basis, in a single update (i.e. each render frame). Broad recommendations: For 2 players, ~64. For 100 players, ~100. For 1k players, ~1k.

    Declaration
    [Tooltip("Capacity of the send queue (per pipeline-stage) on the server.\nThis should be a multiple of the maximum number of packets expected to be sent by the server, across all connections, on a per pipeline-stage basis, in a single update (i.e. each render frame).\n\nFor 2 players, ~128. For 100 players, ~512. For 1k players, ~1k.\n<i>If memory constrained, use minimum, but note it can affect Reliable and Fragmentation pipeline throughput.\nDefault value: 512 i.e. <b>NetworkParameterConstants.SendQueueCapacity</b>")]
    [Min(16)]
    public int ServerSendQueueCapacity
    Field Value
    Type Description
    int
    Examples

    1 packet per pipeline-stage, per connection, for a game supporting, at most, 512 players per server.

    See Also
    sendQueueCapacity

    Properties

    Global

    The Default NetcodeConfig asset, selected in ProjectSettings via the NetCode tab, and fetched at runtime via the PreloadedAssets. Set via UnityEngine.RuntimeInitializeOnLoadMethodAttribute.

    Declaration
    public static NetCodeConfig Global { get; }
    Property Value
    Type Description
    NetCodeConfig

    Methods

    CompareTo(NetCodeConfig)

    Makes Find deterministic.

    Declaration
    public int CompareTo(NetCodeConfig other)
    Parameters
    Type Name Description
    NetCodeConfig other

    Instance of NetCodeConfig

    Returns
    Type Description
    int

    Whether the config and names match.

    Reset()

    Setup default values.

    Declaration
    public void Reset()

    Implements

    IComparable<T>
    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)