Class NetworkConfig
The configuration object used to start server, client and hosts
Inherited Members
Namespace: Unity.Netcode
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
[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 |
---|---|
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
[Tooltip("Whether or not to force clients to be approved before they connect")]
public bool ConnectionApproval
Field Value
Type | Description |
---|---|
Boolean |
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 |
---|---|
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
[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 |
---|---|
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
[Tooltip("Enable this to re-sync the NetworkTime after the initial sync")]
public bool EnableTimeResync
Field Value
Type | Description |
---|---|
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
[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 |
---|---|
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
[Tooltip("Whether or not the netcode should check for differences in the prefab lists at connection")]
public bool ForceSamePrefabs
Field Value
Type | Description |
---|---|
Boolean |
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 |
---|---|
Int32 |
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 |
---|---|
Single |
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 |
---|---|
UInt16 |
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 |
---|---|
Boolean |
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 |
---|---|
Int32 |
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 |
---|---|
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
[Tooltip("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")]
public float SpawnTimeout
Field Value
Type | Description |
---|---|
Single |
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 |
---|---|
UInt32 |
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 |
---|---|
Int32 |
Methods
CompareConfig(UInt64)
Compares a SHA256 hash with the current NetworkConfig instances hash
Declaration
public bool CompareConfig(ulong hash)
Parameters
Type | Name | Description |
---|---|---|
UInt64 | hash |
Returns
Type | Description |
---|---|
Boolean |
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(Boolean)
Gets a SHA256 hash of parts of the NetworkConfig instance
Declaration
public ulong GetConfig(bool cache = true)
Parameters
Type | Name | Description |
---|---|---|
Boolean | cache |
Returns
Type | Description |
---|---|
UInt64 |
ToBase64()
Returns a base64 encoded version of the configuration
Declaration
public string ToBase64()
Returns
Type | Description |
---|---|
String |