Skip to main content

Unity.Netcode.NetworkConfig

The configuration object used to start server, client and hosts

Inheritance#

System.Object

NetworkConfig

Inherited Members#

System.Object.Equals(System.Object)

System.Object.Equals(System.Object, System.Object)

System.Object.GetHashCode()

System.Object.GetType()

System.Object.MemberwiseClone()

System.Object.ReferenceEquals(System.Object, System.Object)

System.Object.ToString()

Syntax#
[Serializable]
public class NetworkConfig

Fields#

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#
public int ClientConnectionBufferTimeout
Field Value#
TypeDescription
System.Int32
Remarks#

The period begins after the Connect is received on the server. The period ends once the server finishes processing a Unity.Netcode.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 Unity.Netcode.ConnectionRequestMessage, and the server processing that message through ConnectionApproval.

This setting is server-side only.

ConnectionApproval#

Whether or not to use connection approval

Declaration#
public bool ConnectionApproval
Field Value#
TypeDescription
System.Boolean

ConnectionData#

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

Declaration#
public byte[] ConnectionData
Field Value#
TypeDescription
System.Byte[]

EnableNetworkLogs#

Whether or not to enable network logs.

Declaration#
public bool EnableNetworkLogs
Field Value#
TypeDescription
System.Boolean

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#
public bool EnableSceneManagement
Field Value#
TypeDescription
System.Boolean

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#
public bool EnableTimeResync
Field Value#
TypeDescription
System.Boolean

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#
public bool EnsureNetworkVariableLengthSafety
Field Value#
TypeDescription
System.Boolean

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#
public bool ForceSamePrefabs
Field Value#
TypeDescription
System.Boolean

LoadSceneTimeOut#

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

Declaration#
public int LoadSceneTimeOut
Field Value#
TypeDescription
System.Int32

NetworkIdRecycleDelay#

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

Declaration#
public float NetworkIdRecycleDelay
Field Value#
TypeDescription
System.Single

NetworkTransport#

The transport hosts the sever uses

Declaration#
public NetworkTransport NetworkTransport
Field Value#
TypeDescription
NetworkTransport

PlayerPrefab#

The default player prefab

Declaration#
public GameObject PlayerPrefab
Field Value#
TypeDescription
GameObject

ProtocolVersion#

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

Declaration#
public ushort ProtocolVersion
Field Value#
TypeDescription
System.UInt16

RecycleNetworkIds#

If true, NetworkIds will be reused after the NetworkIdRecycleDelay.

Declaration#
public bool RecycleNetworkIds
Field Value#
TypeDescription
System.Boolean

RpcHashSize#

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

Declaration#
public HashSize RpcHashSize
Field Value#
TypeDescription
HashSize

RttAverageSamples#

Declaration#
public const int RttAverageSamples = 5
Field Value#
TypeDescription
System.Int32

RttWindowSize#

Declaration#
public const int RttWindowSize = 64
Field Value#
TypeDescription
System.Int32

SpawnTimeout#

The amount of time a message should be buffered if the asset or object needed to process it doesn't exist yet. If the asset is not added/object is not spawned within this time, it will be dropped.

Declaration#
public float SpawnTimeout
Field Value#
TypeDescription
System.Single

TickRate#

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

Declaration#
public uint TickRate
Field Value#
TypeDescription
System.UInt32

TimeResyncInterval#

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

Declaration#
public int TimeResyncInterval
Field Value#
TypeDescription
System.Int32

Methods#

CompareConfig(UInt64)#

Compares a SHA256 hash with the current NetworkConfig instances hash

Declaration#
public bool CompareConfig(ulong hash)
Parameters#
TypeNameDescription
System.UInt64hash
Returns#
TypeDescription
System.Boolean

FromBase64(String)#

Sets the NetworkConfig data with that from a base64 encoded version

Declaration#
public void FromBase64(string base64)
Parameters#
TypeNameDescription
System.Stringbase64The base64 encoded version

GetConfig(Boolean)#

Gets a SHA256 hash of parts of the NetworkConfig instance

Declaration#
public ulong GetConfig(bool cache = true)
Parameters#
TypeNameDescription
System.Booleancache
Returns#
TypeDescription
System.UInt64

ToBase64()#

Returns a base64 encoded version of the configuration

Declaration#
public string ToBase64()
Returns#
TypeDescription
System.String