Namespace Unity.Netcode
Classes
AnticipatedNetworkVariable<T>
A variable that can be synchronized over the network. This version supports basic client anticipation - the client can set a value on the belief that the server will update it to reflect the same value in a future update (i.e., as the result of an RPC call). This value can then be adjusted as new updates from the server come in, in three basic modes:
- Snap: In this mode (with Stale
Data set to Ignore and no OnHandling Reanticipate(double) callback), the moment a more up-to-date value is received from the authority, it will simply replace the anticipated value, resulting in a "snap" to the new value if it is different from the anticipated value. - Smooth: In this mode (with Stale
Data set to Ignore and an OnHandling Reanticipate(double) callback that calls Smooth(in T, in T, float, SmoothDelegate) from the anticipated value to the authority value with an appropriate Lerp(float, float, float)-style smooth function), when a more up-to-date value is received from the authority, it will interpolate over time from an incorrect anticipated value to the correct authoritative value. - Constant Reanticipation: In this mode (with Stale
Data set to Reanticipate and an OnHandling Reanticipate(double) that calculates a new anticipated value based on the current authoritative value), when a more up-to-date value is received from the authority, user code calculates a new anticipated value, possibly calling Smooth(in T, in T, float, SmoothDelegate) to interpolate between the previous anticipation and the new anticipation. This is useful for values that change frequently and need to constantly be re-evaluated, as opposed to values that change only in response to user action and simply need a one-time anticipation when the user performs that action.
Note that these three modes may be combined. For example, if an On
Arithmetic
Arithmetic helper class
BaseRpcTarget
BitCounter
Utility class to count the number of bytes or bits needed to serialize a value.
BufferedLinearInterpolatorFloat
Solves for incoming values that are jittered Partially solves for message loss. Unclamped lerping helps hide this, but not completely
BufferedLinearInterpolatorQuaternion
Solves for incoming values that are jittered Partially solves for message loss. Unclamped lerping helps hide this, but not completely
BufferedLinearInterpolatorVector3
BufferedLinearInterpolator<T>
Solves for incoming values that are jittered Partially solves for message loss. Unclamped lerping helps hide this, but not completely
BytePacker
Utility class for packing values in serialization.
Byte
ByteUnpacker
Byte Unpacking Helper Class
Use this class to unpack values during deserialization for values that were packed.
Byte
ClientRpcAttribute
Marks a method as ClientRpc.
A ClientRpc marked method will be fired by the server but executed on clients.
CustomMessagingManager
The manager class to manage custom messages, note that this is different from the NetworkManager custom messages. These are named and are much easier to use.
GenerateSerializationForGenericParameterAttribute
Marks a generic parameter in this class as a type that should be serialized through
Network
Network
Network
Network
Network
The parameter is indicated by index (and is 0-indexed); for example:
[SerializesGenericParameter(1)]
public class MyClass<TTypeOne, TTypeTwo>
{
}
This tells the code generation for Network
Note that this is primarily intended to support subtypes of Network
This attribute is properly inherited by subclasses. For example:
[SerializesGenericParameter(0)]
public class MyClass<T>
{
}
public class MySubclass1 : MyClass<Foo>
{
}
public class MySubclass2<T> : MyClass<T>
{
}
[SerializesGenericParameter(1)]
public class MySubclass3<TTypeOne, TTypeTwo> : MyClass<TTypeOne>
{
}
public class MyBehaviour : NetworkBehaviour
{
public MySubclass1 TheValue;
public MySubclass2<Bar> TheValue;
public MySubclass3<Baz, Qux> TheValue;
}
The above code will trigger generation of serialization code for Foo (passed directly to the base class), Bar (passed indirectly to the base class), Baz (passed indirectly to the base class), and Qux (marked as serializable in the subclass).
GenerateSerializationForTypeAttribute
Specifies a specific type that needs serialization to be generated by codegen.
This is only needed in special circumstances where manual serialization is being done.
If you are making a generic network variable-style class, use Generate
This attribute can be attached to any class or method anywhere in the codebase and
will trigger codegen to generate serialization code for the provided type. It only needs
to be included once type per codebase, but including it multiple times for the same type
is safe.
InvalidChannelException
Exception thrown when a specified network channel is invalid
InvalidParentException
Exception thrown when the new parent candidate of the NetworkObject is not valid
NetworkBehaviour
The base class to override to write network code. Inherits MonoBehaviour
NetworkBehaviourUpdater
An helper class that helps NetworkManager update NetworkBehaviours and replicate them down to connected clients.
NetworkClient
A NetworkClient
NetworkConfig
The configuration object used to start server, client and hosts
NetworkConfigurationException
Exception thrown when a change to a configuration is wrong
NetworkConnectionManager
The NGO connection manager handles:
- Client Connections
- Client Approval
- Processing Network
Event s. - Client Disconnection
NetworkList<T>
Event based NetworkVariable container for syncing Lists
NetworkLog
Helper class for logging
NetworkManager
The main component of the library
NetworkManager.ConnectionApprovalResponse
Connection Approval Response
NetworkObject
A component used to identify that a GameObject in the network
NetworkPrefab
Class that represents a NetworkPrefab
NetworkPrefabHandler
Primary handler to add or remove customized spawn and destroy handlers for a network prefab (i.e. a prefab with a NetworkObject component)
Register custom prefab handlers by implementing the INetwork
NetworkPrefabs
A class that represents the runtime aspect of network prefabs. This class contains processed prefabs from the NetworkPrefabsList, as well as additional modifications (additions and removals) made at runtime.
NetworkPrefabsList
A ScriptableObject for holding a network prefabs list, which can be shared between multiple NetworkManagers.
When NetworkManagers hold references to this list, modifications to the list at runtime will be picked up by all NetworkManagers that reference it.
NetworkSceneManager
Main class for managing network scenes when Enable
NetworkSpawnManager
Class that handles object spawning
NetworkTickSystem
Provides discretized time. This is useful for games that require ticks happening at regular interval on the server and clients.
NetworkTimeSystem
Network
NetworkTransport
The generic transport class all Netcode for GameObjects network transport implementations derive from. Use this class to add a custom transport. for an example of how a transport is integrated
NetworkUpdateLoop
Represents the network update loop injected into low-level player loop in Unity.
NetworkVariableBase
Interface for network value containers
NetworkVariableSerializationTypes
This class contains initialization functions for various different types used in NetworkVariables. Generally speaking, these methods are called by a module initializer created by codegen (NetworkBehaviourILPP) and do not need to be called manually.
There are two types of initializers: Serializers and EqualityCheckers. Every type must have an EqualityChecker
registered to it in order to be used in NetworkVariable; however, not all types need a Serializer. Types without
a serializer registered will fall back to using the delegates in User
NetworkVariableSerialization<T>
Support methods for reading/writing NetworkVariables
Because there are multiple overloads of WriteValue/ReadValue based on different generic constraints,
but there's no way to achieve the same thing with a class, this sets up various read/write schemes
based on which constraints are met by T
using reflection, which is done at module load time.
NetworkVariable<T>
A variable that can be synchronized over the network.
NotListeningException
Exception thrown when the operation require NetworkManager to be listening.
NotServerException
Exception thrown when the operation can only be done on the server
PendingClient
Server-Side Only: A class representing a client that is currently in the process of connecting
QuaternionCompressor
A Smallest Three Quaternion Compressor Implementation
RpcAttribute
Represents the common base class for Rpc attributes.
RpcException
RpcTarget
Implementations of the various Send
SceneEvent
Used for local notifications of various scene events. The On
Note: This is only when Enable
*** Do not start new scene events within scene event notification callbacks.
See also:
Scene
ServerRpcAttribute
Marks a method as ServerRpc.
A ServerRpc marked method will be fired by a client but executed on the server.
SpawnStateException
Exception thrown when an object is not yet spawned
TestingNetworkTransport
UserNetworkVariableSerialization<T>
This class is used to register user serialization with NetworkVariables for types that are serialized via user serialization, such as with FastBufferReader and FastBufferWriter extension methods. Finding those methods isn't achievable efficiently at runtime, so this allows users to tell NetworkVariable about those extension methods (or simply pass in a lambda)
VisibilityChangeException
Exception thrown when a visibility change fails
Structs
BitReader
Helper class for doing bitwise reads for a FastBufferReader. Ensures all bitwise reads end on proper byte alignment so FastBufferReader doesn't have to be concerned with misaligned reads.
BitWriter
Helper class for doing bitwise writes for a FastBufferWriter. Ensures all bitwise writes end on proper byte alignment so FastBufferWriter doesn't have to be concerned with misaligned writes.
BufferSerializer<TReaderWriter>
Two-way serializer wrapping FastBufferReader or FastBufferWriter.
Implemented as a ref struct to help enforce the requirement that the BufferSerializer cannot outlive the FBR/FBW it wraps or using it will cause a crash
BufferSerializer doesn't wrap FastBufferReader or FastBufferWriter directly because it can't. ref structs can't implement interfaces, and in order to be able to have two different implementations with the same interface (which allows us to avoid an "if(IsReader)" on every call), the thing directly wrapping the struct has to implement an interface. So IReaderWriter exists as the interface, which is implemented by a normal struct, while the ref struct wraps the normal one to enforce the two above requirements. (Allowing direct access to the IReaderWriter struct would allow dangerous things to happen because the struct's lifetime could outlive the Reader/Writer's.)
ClientRpcParams
Client-Side RPC
Can be used with any client-side remote procedure call
Note: Typically this is used primarily for sending to a specific list
of clients as opposed to the default (all).
Client
ClientRpcReceiveParams
Client-Side RPC
Place holder. Server
ClientRpcSendParams
Client-Side RPC
The send parameters, when sending client RPCs, provides you wil the ability to
target specific clients as a managed or unmanaged list:
Target
ConnectionEventData
Returned as a parameter of the On
FastBufferReader
Optimized class used for reading values from a byte stream
Fast
FastBufferWriter
Optimized class used for writing values into a byte stream
Fast
FastBufferWriter.ForEnums
This empty struct exists to allow overloading WriteValue based on generic constraints. At the bytecode level, constraints aren't included in the method signature, so if multiple methods exist with the same signature, it causes a compile error because they would end up being emitted as the same method, even if the constraints are different. Adding an empty struct with a default value gives them different signatures in the bytecode, which then allows the compiler to do overload resolution based on the generic constraints without the user having to pass the struct in themselves.
FastBufferWriter.ForFixedStrings
This empty struct exists to allow overloading WriteValue based on generic constraints. At the bytecode level, constraints aren't included in the method signature, so if multiple methods exist with the same signature, it causes a compile error because they would end up being emitted as the same method, even if the constraints are different. Adding an empty struct with a default value gives them different signatures in the bytecode, which then allows the compiler to do overload resolution based on the generic constraints without the user having to pass the struct in themselves.
FastBufferWriter.ForGeneric
This empty struct exists to allow overloading WriteValue based on generic constraints. At the bytecode level, constraints aren't included in the method signature, so if multiple methods exist with the same signature, it causes a compile error because they would end up being emitted as the same method, even if the constraints are different. Adding an empty struct with a default value gives them different signatures in the bytecode, which then allows the compiler to do overload resolution based on the generic constraints without the user having to pass the struct in themselves.
FastBufferWriter.ForNetworkSerializable
This empty struct exists to allow overloading WriteValue based on generic constraints. At the bytecode level, constraints aren't included in the method signature, so if multiple methods exist with the same signature, it causes a compile error because they would end up being emitted as the same method, even if the constraints are different. Adding an empty struct with a default value gives them different signatures in the bytecode, which then allows the compiler to do overload resolution based on the generic constraints without the user having to pass the struct in themselves.
FastBufferWriter.ForPrimitives
This empty struct exists to allow overloading WriteValue based on generic constraints. At the bytecode level, constraints aren't included in the method signature, so if multiple methods exist with the same signature, it causes a compile error because they would end up being emitted as the same method, even if the constraints are different. Adding an empty struct with a default value gives them different signatures in the bytecode, which then allows the compiler to do overload resolution based on the generic constraints without the user having to pass the struct in themselves.
FastBufferWriter.ForStructs
This empty struct exists to allow overloading WriteValue based on generic constraints. At the bytecode level, constraints aren't included in the method signature, so if multiple methods exist with the same signature, it causes a compile error because they would end up being emitted as the same method, even if the constraints are different. Adding an empty struct with a default value gives them different signatures in the bytecode, which then allows the compiler to do overload resolution based on the generic constraints without the user having to pass the struct in themselves.
ForceNetworkSerializeByMemcpy<T>
This is a wrapper that adds INetworkSerializeByMemcpy
support to existing structs that the developer
doesn't have the ability to modify (for example, external structs like Guid
).
NetworkBehaviourReference
A helper struct for serializing Network
NetworkListEvent<T>
Struct containing event information about changes to a NetworkList.
NetworkManager.ConnectionApprovalRequest
Connection Approval Request
NetworkObjectReference
A helper struct for serializing Network
NetworkTime
A struct to represent a point of time in a networked game. Time is stored as a combination of amount of passed ticks + a duration offset. This struct is meant to replace the Unity Time API for multiplayer gameplay.
NetworkVariableUpdateTraits
RpcAttribute.RpcAttributeParams
RpcParams
Server-Side RPC
Can be used with any sever-side remote procedure call
Note: typically this is use primarily for the Server
RpcReceiveParams
The receive parameters for server-side remote procedure calls
RpcSendParams
Generic RPC
ServerRpcParams
Server-Side RPC
Can be used with any sever-side remote procedure call
Note: typically this is use primarily for the Server
ServerRpcReceiveParams
The receive parameters for server-side remote procedure calls
ServerRpcSendParams
Server-Side RPC
Place holder. Server
Interfaces
INetworkPrefabInstanceHandler
Interface for customizing, overriding, spawning, and destroying Network Prefabs
Used by Network
INetworkSerializable
Interface for implementing custom serializable types.
INetworkSerializeByMemcpy
This interface is a "tag" that can be applied to a struct to mark that struct as being serializable
by memcpy. It's up to the developer of the struct to analyze the struct's contents and ensure it
is actually serializable by memcpy. This requires all of the members of the struct to be
unmanaged
Plain-Old-Data values - if your struct contains a pointer (or a type that contains a pointer,
like NativeList<T>
), it should be serialized via INetworkSerializable
or via
FastBufferReader
/FastBufferWriter
extension methods.
INetworkUpdateSystem
Defines the required interface of a network update system being executed by the Network
IReaderWriter
Interface for an implementation of one side of a two-way serializer
Enums
ConnectionEvent
The connection event type set within Connection
HashSize
Represents the length of a var int encoded hash Note that the HashSize does not say anything about the actual final output due to the var int encoding It just says how many bytes the maximum will be
LocalDeferMode
LogLevel
Log level
NetworkDelivery
Delivery methods
NetworkEvent
Represents a netEvent when polling
NetworkListEvent<T>.EventType
Enum representing the different operations available for triggering an event.
NetworkPrefabOverride
The method of NetworkPrefab override used to identify the source prefab
NetworkUpdateStage
Defines network update stages being executed by the network update loop. See for more details on update stages: https://docs.unity3d.com/ScriptReference/PlayerLoop.Initialization.html
NetworkVariableReadPermission
The permission types for reading a var
NetworkVariableWritePermission
The permission types for writing a var
PendingClient.State
The states of a connection
RpcDelivery
RPC delivery types
RpcTargetUse
This parameter configures a performance optimization. This optimization is not valid in all situations.
Because BaseRpcTarget is a managed type, allocating a new one is expensive, as it puts pressure on the garbage collector.
SceneEventProgressStatus
Used by Network
Note: This was formally known as SwitchSceneProgress which contained the Async
SceneEventType
The different types of scene events communicated between a server and client.
Used by Network
Note: This is only when Enable
See also:
Scene
SendTo
Configuration for the default method by which an RPC is communicated across the network
StaleDataHandling
Delegates
AnticipatedNetworkVariable<T>.OnAuthoritativeValueChangedDelegate
AnticipatedNetworkVariable<T>.SmoothDelegate
A function to interpolate between two values based on a percentage. See Lerp(float, float, float), Lerp(Vector3, Vector3, float), Slerp(Vector3, Vector3, float), and so on for examples.
CustomMessagingManager.HandleNamedMessageDelegate
Delegate used to handle named messages
CustomMessagingManager.UnnamedMessageDelegate
Delegate used for incoming unnamed messages
NetworkList<T>.OnListChangedDelegate
Delegate type for list changed event
NetworkManager.ReanticipateDelegate
NetworkObject.SpawnDelegate
Delegate type for checking spawn options
NetworkObject.VisibilityDelegate
Delegate type for checking visibility
NetworkSceneManager.OnEventCompletedDelegateHandler
Delegate declaration for the OnLoadEventCompleted and OnUnloadEventCompleted events.
See also:
Load
Unload
NetworkSceneManager.OnLoadCompleteDelegateHandler
Delegate declaration for the OnLoadComplete event.
See also:
Load
NetworkSceneManager.OnLoadDelegateHandler
Delegate declaration for the OnLoad event.
See also:
Loadfor more information
NetworkSceneManager.OnSynchronizeCompleteDelegateHandler
Delegate declaration for the OnSynchronizeComplete event.
See also:
Synchronize
NetworkSceneManager.OnSynchronizeDelegateHandler
Delegate declaration for the OnSynchronize event.
See also:
Synchronize for more information
NetworkSceneManager.OnUnloadCompleteDelegateHandler
Delegate declaration for the OnUnloadComplete event.
See also:
Unload
NetworkSceneManager.OnUnloadDelegateHandler
Delegate declaration for the OnUnload event.
See also:
Unload for more information
NetworkSceneManager.SceneEventDelegate
The delegate callback definition for scene event notifications.
See also:
Scene
Scene
NetworkSceneManager.VerifySceneBeforeLoadingDelegateHandler
Delegate declaration for the Verify
NetworkSceneManager.VerifySceneBeforeUnloadingDelegateHandler
Delegate declaration for the Verify
NetworkTransport.TransportEventDelegate
Delegate for transport network events
NetworkVariableSerialization<T>.EqualsDelegate
A callback to check if two values are equal.
NetworkVariable<T>.CheckExceedsDirtinessThresholdDelegate
NetworkVariable<T>.OnValueChangedDelegate
Delegate type for value changed event
UserNetworkVariableSerialization<T>.DuplicateValueDelegate
The read value delegate handler definition
UserNetworkVariableSerialization<T>.ReadDeltaDelegate
The read value delegate handler definition
UserNetworkVariableSerialization<T>.ReadValueDelegate
The read value delegate handler definition
UserNetworkVariableSerialization<T>.WriteDeltaDelegate
The write value delegate handler definition
UserNetworkVariableSerialization<T>.WriteValueDelegate
The write value delegate handler definition