docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkConfig

    The configuration object used to start server, client and hosts

    Inheritance
    object
    NetworkConfig
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Netcode
    Assembly: Unity.Netcode.Runtime.dll
    Syntax
    [Serializable]
    public class NetworkConfig

    Fields

    AutoSpawnPlayerPrefabClientSide

    Declaration
    [Tooltip("When enabled (default), the player prefab will automatically be spawned (client-side) upon the client being approved and synchronized.")]
    public bool AutoSpawnPlayerPrefabClientSide
    Field Value
    Type Description
    bool

    ClientConnectionBufferTimeout

    The amount of seconds for the server to wait for the connection approval handshake to complete before the client is disconnected.

    If the timeout is reached before approval is completed the client will be disconnected.

    Declaration
    [Tooltip("The amount of seconds for the server to wait for the connection approval handshake to complete before the client is disconnected")]
    public int ClientConnectionBufferTimeout
    Field Value
    Type Description
    int
    Remarks

    The period begins after the Connect is received on the server. The period ends once the server finishes processing a ConnectionRequestMessage from the client.

    This setting is independent of any Transport-level timeouts that may be in effect. It covers the time between the connection being established on the Transport layer, the client sending a ConnectionRequestMessage, and the server processing that message through ConnectionApproval.

    This setting is server-side only.

    ConnectionApproval

    Whether or not to use connection approval

    Declaration
    [Tooltip("Whether or not to force clients to be approved before they connect")]
    public bool ConnectionApproval
    Field Value
    Type Description
    bool

    ConnectionData

    The data to send during connection which can be used to decide on if a client should get accepted

    Declaration
    [Tooltip("The connection data sent along with connection requests")]
    public byte[] ConnectionData
    Field Value
    Type Description
    byte[]

    EnableNetworkLogs

    Whether or not to enable network logs.

    Declaration
    public bool EnableNetworkLogs
    Field Value
    Type Description
    bool

    EnableSceneManagement

    Enables scene management. This will allow network scene switches and automatic scene difference corrections upon connect. SoftSynced scene objects wont work with this disabled. That means that disabling SceneManagement also enables PrefabSync.

    Declaration
    [Tooltip("Enables scene management. This will allow network scene switches and automatic scene difference corrections upon connect.\nSoftSynced scene objects wont work with this disabled. That means that disabling SceneManagement also enables PrefabSync.")]
    public bool EnableSceneManagement
    Field Value
    Type Description
    bool

    EnableTimeResync

    If your logic uses the NetworkTime, this should probably be turned off. If however it's needed to maximize accuracy, this is recommended to be turned on

    Declaration
    [Tooltip("Enable this to re-sync the NetworkTime after the initial sync")]
    public bool EnableTimeResync
    Field Value
    Type Description
    bool

    EnsureNetworkVariableLengthSafety

    Whether or not to ensure that NetworkVariables can be read even if a client accidentally writes where its not allowed to. This costs some CPU and bandwidth.

    Declaration
    [Tooltip("Ensures that NetworkVariables can be read even if a client accidental writes where its not allowed to. This will cost some CPU time and bandwidth")]
    public bool EnsureNetworkVariableLengthSafety
    Field Value
    Type Description
    bool

    ForceSamePrefabs

    Whether or not the netcode should check for differences in the prefabs at connection. If you dynamically add prefabs at runtime, turn this OFF

    Declaration
    [Tooltip("Whether or not the netcode should check for differences in the prefab lists at connection")]
    public bool ForceSamePrefabs
    Field Value
    Type Description
    bool

    LoadSceneTimeOut

    The amount of seconds to wait for all clients to load or unload a requested scene

    Declaration
    [Tooltip("The amount of seconds to wait for all clients to load or unload a requested scene (only when EnableSceneManagement is enabled)")]
    public int LoadSceneTimeOut
    Field Value
    Type Description
    int

    NetworkIdRecycleDelay

    The amount of seconds a NetworkId has to be unused in order for it to be reused.

    Declaration
    [Tooltip("The amount of seconds a NetworkId has to unused in order for it to be reused")]
    public float NetworkIdRecycleDelay
    Field Value
    Type Description
    float

    NetworkProfilingMetrics

    When enabled (default, this enables network profiling information. This does come with a per message processing cost. Network profiling information is automatically disabled in release builds.

    Declaration
    [Tooltip("Enable (default) if you want to profile network messages with development builds and defaults to being disabled in release builds. When disabled, network messaging profiling will be disabled in development builds.")]
    public bool NetworkProfilingMetrics
    Field Value
    Type Description
    bool

    NetworkTopology

    Declaration
    [Tooltip("Determines whether to use the client-server or distributed authority network topology.")]
    public NetworkTopologyTypes NetworkTopology
    Field Value
    Type Description
    NetworkTopologyTypes

    NetworkTransport

    The transport hosts the sever uses

    Declaration
    [Tooltip("The NetworkTransport to use")]
    public NetworkTransport NetworkTransport
    Field Value
    Type Description
    NetworkTransport

    PlayerPrefab

    The default player prefab

    Declaration
    [Tooltip("When set, NetworkManager will automatically create and spawn the assigned player prefab. This can be overridden by adding it to the NetworkPrefabs list and selecting override.")]
    public GameObject PlayerPrefab
    Field Value
    Type Description
    GameObject

    Prefabs

    Declaration
    [SerializeField]
    public NetworkPrefabs Prefabs
    Field Value
    Type Description
    NetworkPrefabs

    ProtocolVersion

    The protocol version. Different versions doesn't talk to each other.

    Declaration
    [Tooltip("Use this to make two builds incompatible with each other")]
    public ushort ProtocolVersion
    Field Value
    Type Description
    ushort

    RecycleNetworkIds

    If true, NetworkIds will be reused after the NetworkIdRecycleDelay.

    Declaration
    [Tooltip("If true, NetworkIds will be reused after the NetworkIdRecycleDelay")]
    public bool RecycleNetworkIds
    Field Value
    Type Description
    bool

    RpcHashSize

    Decides how many bytes to use for Rpc messaging. Leave this to 2 bytes unless you are facing hash collisions

    Declaration
    [Tooltip("The maximum amount of bytes to use for RPC messages.")]
    public HashSize RpcHashSize
    Field Value
    Type Description
    HashSize

    RttAverageSamples

    The number of RTT samples that is kept as an average for calculations

    Declaration
    public const int RttAverageSamples = 5
    Field Value
    Type Description
    int

    RttWindowSize

    The number of slots used for RTT calculations. This is the maximum amount of in-flight messages

    Declaration
    public const int RttWindowSize = 64
    Field Value
    Type Description
    int

    SpawnTimeout

    The amount of time a message will be held (deferred) if the destination NetworkObject needed to process the message doesn't exist yet. If the NetworkObject is not spawned within this time period, all deferred messages for that NetworkObject will be dropped.

    Declaration
    [Tooltip("The amount of time a message will be held (deferred) if the destination NetworkObject needed to process the message doesn't exist yet. If the NetworkObject is not spawned within this time period, all deferred messages for that NetworkObject will be dropped.")]
    public float SpawnTimeout
    Field Value
    Type Description
    float

    TickRate

    The tickrate of network ticks. This value controls how often netcode runs user code and sends out data.

    Declaration
    [Tooltip("The tickrate. This value controls how often netcode runs user code and sends out data. The value is in 'ticks per seconds' which means a value of 50 will result in 50 ticks being executed per second or a fixed delta time of 0.02.")]
    public uint TickRate
    Field Value
    Type Description
    uint

    TimeResyncInterval

    If time re-sync is turned on, this specifies the interval between syncs in seconds.

    Declaration
    [Tooltip("The amount of seconds between re-syncs of NetworkTime, if enabled")]
    public int TimeResyncInterval
    Field Value
    Type Description
    int

    UseCMBService

    Declaration
    [HideInInspector]
    public bool UseCMBService
    Field Value
    Type Description
    bool

    Methods

    CompareConfig(ulong)

    Compares a SHA256 hash with the current NetworkConfig instances hash

    Declaration
    public bool CompareConfig(ulong hash)
    Parameters
    Type Name Description
    ulong hash
    Returns
    Type Description
    bool

    FromBase64(string)

    Sets the NetworkConfig data with that from a base64 encoded version

    Declaration
    public void FromBase64(string base64)
    Parameters
    Type Name Description
    string base64

    The base64 encoded version

    GetConfig(bool)

    Gets a SHA256 hash of parts of the NetworkConfig instance

    Declaration
    public ulong GetConfig(bool cache = true)
    Parameters
    Type Name Description
    bool cache
    Returns
    Type Description
    ulong

    ToBase64()

    Returns a base64 encoded version of the configuration

    Declaration
    public string ToBase64()
    Returns
    Type Description
    string
    In This Article
    Back to top
    Copyright © 2024 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)