docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkManager

    The main component of the library

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    NetworkManager
    Implements
    INetworkUpdateSystem
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.Netcode
    Assembly: solution.dll
    Syntax
    [AddComponentMenu("Netcode/Network Manager", -100)]
    public class NetworkManager : MonoBehaviour, INetworkUpdateSystem

    Fields

    Name Description
    LogLevel

    The log level to use

    NetworkConfig

    The current netcode project configuration

    PendingClients

    Gets a dictionary of the clients that have been accepted by the transport but are still pending by the Netcode. This is only populated on the server.

    RunInBackground

    Gets or sets if the application should be set to run in background

    ServerClientId

    The client id used to represent the server

    Properties

    Name Description
    ConnectedClients

    Gets a dictionary of connected clients and their clientId keys. This is only accessible on the server.

    ConnectedClientsIds

    Gets a list of just the IDs of all connected clients. This is only accessible on the server.

    ConnectedClientsList

    Gets a list of connected clients. This is only accessible on the server.

    ConnectedHostname

    The current host name we are connected to, used to validate certificate

    ConnectionApprovalCallback

    The callback to invoke during connection approval. Allows client code to decide whether or not to allow incoming client connection

    CustomMessagingManager

    Gets the CustomMessagingManager for this NetworkManager

    DisconnectReason

    When disconnected from the server, the server may send a reason. If a reason was sent, this property will tell client code what the reason was. It should be queried after the OnClientDisconnectCallback is called

    IsApproved

    Is true when the client has been approved.

    IsClient

    Gets Whether or not a client is running

    IsConnectedClient

    When true, the client is connected, approved, and synchronized with the server. IsConnected
    IsApproved

    IsHost

    Gets if we are running as host

    IsListening

    Is true when a server or host is listening for connections. Is true when a client is connecting or connected to a network session. Is false when not listening, connecting, or connected.

    IsServer

    Gets Whether or not a server is running

    LocalClient

    Gets the local NetworkClient for this client.

    LocalClientId

    Returns ServerClientId if IsServer or LocalClientId if not

    LocalTime

    The local NetworkTime

    MaximumFragmentedMessageSize

    Sets the maximum size of a message (or message batch) passed through the transport with the ReliableFragmented delivery. Warning: setting this value too low may result in the SDK becoming non-functional with projects that have a large number of NetworkBehaviours or NetworkVariables, as the SDK relies on the transport's ability to fragment some messages when they grow beyond the MTU size.

    MaximumTransmissionUnitSize

    Sets the maximum size of a single non-fragmented message (or message batch) passed through the transport. This should represent the transport's default MTU size, minus any transport-level overhead. This value will be used for any remote endpoints that haven't had per-endpoint MTUs set. This value is also used as the size of the temporary buffer used when serializing a single message (to avoid serializing multiple times when sending to multiple endpoints), and thus should be large enough to ensure it can hold each message type. This value defaults to 1296.

    NetworkTickSystem

    Accessor property for the NetworkTickSystem of the NetworkManager.

    NetworkTimeSystem

    Accessor property for the NetworkTimeSystem of the NetworkManager. Prefer the use of the LocalTime and ServerTime properties

    PrefabHandler

    The NetworkPrefabHandler instance created after starting the NetworkManager

    SceneManager

    The NetworkSceneManager instance created after starting the NetworkManager

    ServerTime

    The NetworkTime on the server

    ShutdownInProgress

    Can be used to determine if the NetworkManager is currently shutting itself down

    Singleton

    The singleton instance of the NetworkManager

    SpawnManager

    Gets the SpawnManager for this NetworkManager

    Methods

    Name Description
    AddNetworkPrefab(GameObject)

    AddNetworkPrefab(GameObject)

    DisconnectClient(ulong)

    Disconnects the remote client.

    DisconnectClient(ulong, string)

    Disconnects the remote client.

    GetNetworkPrefabOverride(GameObject)

    GetNetworkPrefabOverride(GameObject)

    GetPeerMTU(ulong)

    Queries the current MTU size for a client. If no MTU has been set for that client, will return MaximumTransmissionUnitSize

    NetworkUpdate(NetworkUpdateStage)

    The update method that is being executed in the context of related NetworkUpdateStage.

    RemoveNetworkPrefab(GameObject)

    RemoveNetworkPrefab(GameObject)

    SetPeerMTU(ulong, int)

    Set the maximum transmission unit for a specific peer. This determines the maximum size of a message batch that can be sent to that client. If not set for any given client, MaximumTransmissionUnitSize will be used instead.

    SetSingleton()

    Set this NetworkManager instance as the static NetworkManager singleton

    Shutdown(bool)

    Globally shuts down the library. Disconnects clients if connected and stops server if running.

    StartClient()

    Starts a client

    StartHost()

    Starts a Host

    StartServer()

    Starts a server

    Events

    Name Description
    OnClientConnectedCallback

    The callback to invoke once a client connects. This callback is only ran on the server and on the local client that connects.

    OnClientDisconnectCallback

    The callback to invoke when a client disconnects. This callback is only ran on the server and on the local client that disconnects.

    OnClientStarted

    The callback to invoke once the local client is ready

    OnClientStopped

    The callback to invoke once the local client stops

    OnServerStarted

    This callback is invoked when the local server is started and listening for incoming connections.

    OnServerStopped

    This callback is invoked once the local server is stopped.

    OnTransportFailure

    The callback to invoke if the NetworkTransport fails.

    Extension Methods

    NetworkUpdateLoop.RegisterAllNetworkUpdates(INetworkUpdateSystem)
    NetworkUpdateLoop.RegisterNetworkUpdate(INetworkUpdateSystem, NetworkUpdateStage)
    NetworkUpdateLoop.UnregisterAllNetworkUpdates(INetworkUpdateSystem)
    NetworkUpdateLoop.UnregisterNetworkUpdate(INetworkUpdateSystem, NetworkUpdateStage)
    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)