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)
    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.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: MLAPI
    Assembly: Unity.Multiplayer.MLAPI.Runtime.dll
    Syntax
    [AddComponentMenu("MLAPI/NetworkManager", -100)]
    public class NetworkManager : MonoBehaviour, INetworkUpdateSystem

    Fields

    ConnectedClients

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

    Declaration
    public readonly Dictionary<ulong, NetworkClient> ConnectedClients
    Field Value
    Type Description
    Dictionary<ulong, NetworkClient>

    ConnectedClientsList

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

    Declaration
    public readonly List<NetworkClient> ConnectedClientsList
    Field Value
    Type Description
    List<NetworkClient>

    DontDestroy

    Gets or sets if the NetworkManager should be marked as DontDestroyOnLoad

    Declaration
    [HideInInspector]
    public bool DontDestroy
    Field Value
    Type Description
    bool

    LogLevel

    The log level to use

    Declaration
    [HideInInspector]
    public LogLevel LogLevel
    Field Value
    Type Description
    LogLevel

    NetworkConfig

    The current NetworkConfig

    Declaration
    [HideInInspector]
    public NetworkConfig NetworkConfig
    Field Value
    Type Description
    NetworkConfig

    PendingClients

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

    Declaration
    public readonly Dictionary<ulong, PendingClient> PendingClients
    Field Value
    Type Description
    Dictionary<ulong, PendingClient>

    RunInBackground

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

    Declaration
    [HideInInspector]
    public bool RunInBackground
    Field Value
    Type Description
    bool

    Properties

    ConnectedHostname

    The current hostname we are connected to, used to validate certificate

    Declaration
    public string ConnectedHostname { get; }
    Property Value
    Type Description
    string

    IsClient

    Gets Whether or not a client is running

    Declaration
    public bool IsClient { get; }
    Property Value
    Type Description
    bool

    IsConnectedClient

    Gets if we are connected as a client

    Declaration
    public bool IsConnectedClient { get; }
    Property Value
    Type Description
    bool

    IsHost

    Gets if we are running as host

    Declaration
    public bool IsHost { get; }
    Property Value
    Type Description
    bool

    IsListening

    Gets Whether or not we are listening for connections

    Declaration
    public bool IsListening { get; }
    Property Value
    Type Description
    bool

    IsServer

    Gets Whether or not a server is running

    Declaration
    public bool IsServer { get; }
    Property Value
    Type Description
    bool

    LocalClientId

    The clientId the server calls the local client by, only valid for clients

    Declaration
    public ulong LocalClientId { get; }
    Property Value
    Type Description
    ulong

    NetworkTime

    A synchronized time, represents the time in seconds since the server application started. Is replicated across all clients

    Declaration
    public float NetworkTime { get; }
    Property Value
    Type Description
    float

    ServerClientId

    Gets the networkId of the server

    Declaration
    public ulong ServerClientId { get; }
    Property Value
    Type Description
    ulong

    Singleton

    The singleton instance of the NetworkManager

    Declaration
    public static NetworkManager Singleton { get; }
    Property Value
    Type Description
    NetworkManager

    Methods

    DisconnectClient(ulong)

    Disconnects the remote client.

    Declaration
    public void DisconnectClient(ulong clientId)
    Parameters
    Type Name Description
    ulong clientId

    The ClientId to disconnect

    NetworkUpdate(NetworkUpdateStage)

    Declaration
    public void NetworkUpdate(NetworkUpdateStage updateStage)
    Parameters
    Type Name Description
    NetworkUpdateStage updateStage

    SetSingleton()

    Declaration
    public void SetSingleton()

    Shutdown()

    Declaration
    public void Shutdown()

    StartClient()

    Starts a client

    Declaration
    public SocketTasks StartClient()
    Returns
    Type Description
    SocketTasks

    StartHost(Vector3?, Quaternion?, bool?, ulong?, Stream)

    Starts a Host

    Declaration
    public SocketTasks StartHost(Vector3? position = null, Quaternion? rotation = null, bool? createPlayerObject = null, ulong? prefabHash = null, Stream payloadStream = null)
    Parameters
    Type Name Description
    Vector3? position
    Quaternion? rotation
    bool? createPlayerObject
    ulong? prefabHash
    Stream payloadStream
    Returns
    Type Description
    SocketTasks

    StartServer()

    Starts a server

    Declaration
    public SocketTasks StartServer()
    Returns
    Type Description
    SocketTasks

    StopClient()

    Stops the running client

    Declaration
    public void StopClient()

    StopHost()

    Stops the running host

    Declaration
    public void StopHost()

    StopServer()

    Stops the running server

    Declaration
    public void StopServer()

    Events

    ConnectionApprovalCallback

    The callback to invoke during connection approval

    Declaration
    public event Action<byte[], ulong, NetworkManager.ConnectionApprovedDelegate> ConnectionApprovalCallback
    Event Type
    Type Description
    Action<byte[], ulong, NetworkManager.ConnectionApprovedDelegate>

    OnClientConnectedCallback

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

    Declaration
    public event Action<ulong> OnClientConnectedCallback
    Event Type
    Type Description
    Action<ulong>

    OnClientDisconnectCallback

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

    Declaration
    public event Action<ulong> OnClientDisconnectCallback
    Event Type
    Type Description
    Action<ulong>

    OnPerformanceDataEvent

    Declaration
    public static event NetworkManager.PerformanceDataEventHandler OnPerformanceDataEvent
    Event Type
    Type Description
    NetworkManager.PerformanceDataEventHandler

    OnServerStarted

    The callback to invoke once the server is ready

    Declaration
    public event Action OnServerStarted
    Event Type
    Type Description
    Action

    Implements

    INetworkUpdateSystem

    Extension Methods

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