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: MLAPI.Configuration
    Assembly: Unity.Multiplayer.MLAPI.Runtime.dll
    Syntax
    [Serializable]
    public class NetworkConfig

    Fields

    AllowRuntimeSceneChanges

    Whether or not runtime scene changes should be allowed and expected. If this is true, clients with different initial configurations will not work together.

    Declaration
    [Tooltip("Whether or not runtime scene changes should be allowed and expected.\n If this is true, clients with different initial configurations will not work together.")]
    public bool AllowRuntimeSceneChanges
    Field Value
    Type Description
    bool

    ClientConnectionBufferTimeout

    The amount of seconds to wait for handshake to complete before timing out a client

    Declaration
    [Tooltip("The amount of seconds to wait for the handshake to complete before the client times out")]
    public int ClientConnectionBufferTimeout
    Field Value
    Type Description
    int

    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[]

    CreatePlayerPrefab

    Whether or not a player object should be created by default. This value can be overriden on a case by case basis with ConnectionApproval.

    Declaration
    [Tooltip("Whether or not a player object should be created by default. This value can be overriden on a case by case basis with ConnectionApproval.")]
    public bool CreatePlayerPrefab
    Field Value
    Type Description
    bool

    EnableMessageBuffering

    Whether or not message buffering should be enabled. This will resolve most out of order messages during spawn.

    Declaration
    [Tooltip("Whether or not message buffering should be enabled. This will resolve most out of order messages during spawn")]
    public bool EnableMessageBuffering
    Field Value
    Type Description
    bool

    EnableNetworkLogs

    Whether or not to enable network logs.

    Declaration
    public bool EnableNetworkLogs
    Field Value
    Type Description
    bool

    EnableNetworkVariable

    Whether or not to enable the NetworkVariable system. This system runs in the Update loop and will degrade performance, but it can be a huge convenience. Only turn it off if you have no need for the NetworkVariable system.

    Declaration
    [Tooltip("Whether or not to enable the NetworkVariable system")]
    public bool EnableNetworkVariable
    Field Value
    Type Description
    bool

    EnableSceneManagement

    Enables scene management. This will allow network scene switches and automatic scene diff 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 diff 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 resync 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 bandwdith.

    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

    EventTickrate

    The amount of times per second internal frame events will occur, e.g. send checking.

    Declaration
    [Tooltip("The amount of times per second the internal event loop will run. This includes for example NetworkVariable checking and LagCompensation tracking")]
    public int EventTickrate
    Field Value
    Type Description
    int

    ForceSamePrefabs

    Whether or not the MLAPI 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 MLAPI 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 on all clients to load requested scene before the SwitchSceneProgress onComplete callback, that waits for all clients to complete loading, is called anyway.

    Declaration
    [Tooltip("The amount of seconds to wait for all clients to load a requested scene")]
    public int LoadSceneTimeOut
    Field Value
    Type Description
    int

    MaxReceiveEventsPerTickRate

    The max amount of messages to process per ReceiveTickrate. This is to prevent flooding.

    Declaration
    [Tooltip("The maximum amount of Receive events to poll per Receive tick. This is to prevent flooding and freezing on the server")]
    public int MaxReceiveEventsPerTickRate
    Field Value
    Type Description
    int

    MessageBufferTimeout

    The amount of time a message should be buffered for without being consumed. If it is not consumed within this time, it will be dropped.

    Declaration
    [Tooltip("The amount of time a message should be buffered for without being consumed. If it is not consumed within this time, it will be dropped")]
    public float MessageBufferTimeout
    Field Value
    Type Description
    float

    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

    NetworkPrefabs

    A list of spawnable prefabs

    Declaration
    [Tooltip("The prefabs that can be spawned across the network")]
    public List<NetworkPrefab> NetworkPrefabs
    Field Value
    Type Description
    List<NetworkPrefab>

    NetworkTickIntervalSec

    Duration in seconds between network ticks.

    Declaration
    [Tooltip("Duration in seconds between network ticks")]
    public float NetworkTickIntervalSec
    Field Value
    Type Description
    float

    NetworkTransport

    The transport hosts the sever uses

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

    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

    ReceiveTickrate

    Amount of times per second the receive queue is emptied and all messages inside are processed.

    Declaration
    [Tooltip("The amount of times per second the receive queue is emptied from pending incoming messages")]
    public int ReceiveTickrate
    Field Value
    Type Description
    int

    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

    RegisteredScenes

    A list of SceneNames that can be used during networked games.

    Declaration
    [Tooltip("The Scenes that can be switched to by the server")]
    public List<string> RegisteredScenes
    Field Value
    Type Description
    List<string>

    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. Leave this to 2 unless you are facing hash collisions")]
    public HashSize RpcHashSize
    Field Value
    Type Description
    HashSize

    SecondsHistory

    The amount of seconds to keep a lag compensation position history

    Declaration
    [Tooltip("The amount of seconds to keep lag compensation position history")]
    public int SecondsHistory
    Field Value
    Type Description
    int

    TimeResyncInterval

    If time resync is turned on, this specifies the interval between syncs in seconds.

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

    UsePrefabSync

    If true, all NetworkObjects need to be prefabs and all scene objects will be replaced on server side which causes all serialization to be lost. Useful for multi project setups If false, Only non scene objects have to be prefabs. Scene objects will be matched using their PrefabInstanceId which can be precomputed globally for a scene at build time. Useful for single projects

    Declaration
    [Tooltip("If true, all NetworkObjects need to be prefabs and all scene objects will be replaced on server side which causes all serialization to be lost. Useful for multi project setups\nIf false, Only non scene objects have to be prefabs. Scene objects will be matched using their PrefabInstanceId which can be precomputed globally for a scene at build time. Useful for single projects")]
    public bool UsePrefabSync
    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 config

    Declaration
    public string ToBase64()
    Returns
    Type Description
    string
    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)