docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CustomNetworkManagerWithCallbacks

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    NetworkManager
    CustomNetworkManagerWithCallbacks
    Inherited Members
    NetworkManager.matchName
    NetworkManager.matchSize
    NetworkManager.networkPort
    NetworkManager.serverBindToIP
    NetworkManager.serverBindAddress
    NetworkManager.networkAddress
    NetworkManager.dontDestroyOnLoad
    NetworkManager.runInBackground
    NetworkManager.scriptCRCCheck
    NetworkManager.sendPeerInfo
    NetworkManager.maxDelay
    NetworkManager.logLevel
    NetworkManager.playerPrefab
    NetworkManager.autoCreatePlayer
    NetworkManager.playerSpawnMethod
    NetworkManager.offlineScene
    NetworkManager.onlineScene
    NetworkManager.spawnPrefabs
    NetworkManager.startPositions
    NetworkManager.customConfig
    NetworkManager.connectionConfig
    NetworkManager.globalConfig
    NetworkManager.maxConnections
    NetworkManager.channels
    NetworkManager.secureTunnelEndpoint
    NetworkManager.useWebSockets
    NetworkManager.useSimulator
    NetworkManager.simulatedLatency
    NetworkManager.packetLossPercentage
    NetworkManager.matchHost
    NetworkManager.matchPort
    NetworkManager.clientLoadedScene
    NetworkManager.migrationManager
    NetworkManager.numPlayers
    NetworkManager.defaultTransport
    NetworkManager.activeTransport
    NetworkManager.networkSceneName
    NetworkManager.isNetworkActive
    NetworkManager.client
    NetworkManager.matchInfo
    NetworkManager.matchMaker
    NetworkManager.matches
    NetworkManager.singleton
    NetworkManager.SetupMigrationManager(NetworkMigrationManager)
    NetworkManager.StartServer(ConnectionConfig, int)
    NetworkManager.StartServer()
    NetworkManager.StartServer(MatchInfo)
    NetworkManager.UseExternalClient(NetworkClient)
    NetworkManager.StartClient(MatchInfo, ConnectionConfig, int)
    NetworkManager.StartClient(MatchInfo)
    NetworkManager.StartClient()
    NetworkManager.StartClient(MatchInfo, ConnectionConfig)
    NetworkManager.StartHost(ConnectionConfig, int)
    NetworkManager.StartHost(MatchInfo)
    NetworkManager.StartHost()
    NetworkManager.StopHost()
    NetworkManager.StopServer()
    NetworkManager.StopClient()
    NetworkManager.ServerChangeScene(string)
    NetworkManager.RegisterStartPosition(Transform)
    NetworkManager.UnRegisterStartPosition(Transform)
    NetworkManager.IsClientConnected()
    NetworkManager.Shutdown()
    NetworkManager.OnServerConnect(NetworkConnection)
    NetworkManager.OnServerDisconnect(NetworkConnection)
    NetworkManager.OnServerReady(NetworkConnection)
    NetworkManager.OnServerAddPlayer(NetworkConnection, short, NetworkReader)
    NetworkManager.OnServerAddPlayer(NetworkConnection, short)
    NetworkManager.GetStartPosition()
    NetworkManager.OnServerRemovePlayer(NetworkConnection, PlayerController)
    NetworkManager.OnServerError(NetworkConnection, int)
    NetworkManager.OnServerSceneChanged(string)
    NetworkManager.OnClientConnect(NetworkConnection)
    NetworkManager.OnClientDisconnect(NetworkConnection)
    NetworkManager.OnClientError(NetworkConnection, int)
    NetworkManager.OnClientNotReady(NetworkConnection)
    NetworkManager.OnClientSceneChanged(NetworkConnection)
    NetworkManager.StartMatchMaker()
    NetworkManager.StopMatchMaker()
    NetworkManager.SetMatchHost(string, int, bool)
    NetworkManager.OnStartHost()
    NetworkManager.OnStartServer()
    NetworkManager.OnStartClient(NetworkClient)
    NetworkManager.OnStopServer()
    NetworkManager.OnStopClient()
    NetworkManager.OnStopHost()
    NetworkManager.OnMatchCreate(bool, string, MatchInfo)
    NetworkManager.OnMatchList(bool, string, List<MatchInfoSnapshot>)
    NetworkManager.OnMatchJoined(bool, string, MatchInfo)
    NetworkManager.OnDestroyMatch(bool, string)
    NetworkManager.OnDropConnection(bool, string)
    NetworkManager.OnSetMatchAttributes(bool, string)
    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: Global Namespace
    Assembly: com.unity.multiplayer-hlapi.Tests.dll
    Syntax
    public class CustomNetworkManagerWithCallbacks : NetworkManager

    Fields

    actualListOfCallbacks

    Declaration
    public List<string> actualListOfCallbacks
    Field Value
    Type Description
    List<string>

    isStartHostPartDone

    Declaration
    public bool isStartHostPartDone
    Field Value
    Type Description
    bool

    isStopHostPartDone

    Declaration
    public bool isStopHostPartDone
    Field Value
    Type Description
    bool

    Methods

    OnClientConnect(NetworkConnection)

    Called on the client when connected to a server.

    The default implementation of this function sets the client as ready and adds a player. Override the function to dictate what happens when the client connects.

    //Attach this script to a GameObject
                                                                                                                                                                          //Create a Text GameObject(Create>UI>Text) and attach it to the Text field in the Inspector window
                                                                                                                                                                          //This script changes the Text depending on if a client connects or disconnects to the server
    
                                                                                                                                                                      using UnityEngine;
                                                                                                                                                                      using UnityEngine.Networking;
                                                                                                                                                                      using UnityEngine.UI;
    
                                                                                                                                                                      public class Example : NetworkManager
                                                                                                                                                                      {
                                                                                                                                                                         //Assign a Text component in the GameObject's Inspector
                                                                                                                                                                         public Text m_ClientText;
    
                                                                                                                                                                         //Detect when a client connects to the Server
                                                                                                                                                                         public override void OnClientConnect(NetworkConnection connection)
                                                                                                                                                                         {
                                                                                                                                                                             //Change the text to show the connection on the client side
                                                                                                                                                                             m_ClientText.text =  " " + connection.connectionId + " Connected!";
                                                                                                                                                                         }
    
                                                                                                                                                                         //Detect when a client connects to the Server
                                                                                                                                                                         public override void OnClientDisconnect(NetworkConnection connection)
                                                                                                                                                                         {
                                                                                                                                                                             //Change the text to show the connection loss on the client side
                                                                                                                                                                             m_ClientText.text = "Connection" + connection.connectionId + " Lost!";
                                                                                                                                                                         }
                                                                                                                                                                      }</code></pre>
    
    Declaration
    public override void OnClientConnect(NetworkConnection conn)
    Parameters
    Type Name Description
    NetworkConnection conn

    Connection to the server.

    Overrides
    NetworkManager.OnClientConnect(NetworkConnection)

    OnServerAddPlayer(NetworkConnection, short)

    Declaration
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    Parameters
    Type Name Description
    NetworkConnection conn
    short playerControllerId
    Overrides
    NetworkManager.OnServerAddPlayer(NetworkConnection, short)

    OnServerConnect(NetworkConnection)

    Called on the server when a new client connects.

    Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.

    //Attach this script to a GameObject and add a NetworkHUD component to the GameObject.
                                                                                                                                                                           //Create a Text GameObject (Create>UI>Text) and attach it in the Text field in the Inspector.
                                                                                                                                                                           //This script changes Text on the screen when a client connects to the server
    
                                                                                                                                                                       using UnityEngine;
                                                                                                                                                                       using UnityEngine.Networking;
                                                                                                                                                                       using UnityEngine.UI;
    
                                                                                                                                                                       public class OnServerConnectExample : NetworkManager
                                                                                                                                                                       {
                                                                                                                                                                          //Assign a Text component in the GameObject's Inspector
                                                                                                                                                                          public Text m_Text;
    
                                                                                                                                                                          //Detect when a client connects to the Server
                                                                                                                                                                          public override void OnServerConnect(NetworkConnection connection)
                                                                                                                                                                          {
                                                                                                                                                                              //Change the text to show the connection and the client's ID
                                                                                                                                                                              m_Text.text = "Client " + connection.connectionId + " Connected!";
                                                                                                                                                                          }
                                                                                                                                                                       }</code></pre>
    
    Declaration
    public override void OnServerConnect(NetworkConnection conn)
    Parameters
    Type Name Description
    NetworkConnection conn

    Connection from client.

    Overrides
    NetworkManager.OnServerConnect(NetworkConnection)

    OnServerReady(NetworkConnection)

    Called on the server when a client is ready.

    The default implementation of this function calls NetworkServer.SetClientReady() to continue the network setup process.

    Declaration
    public override void OnServerReady(NetworkConnection conn)
    Parameters
    Type Name Description
    NetworkConnection conn

    Connection from client.

    Overrides
    NetworkManager.OnServerReady(NetworkConnection)

    OnStartClient(NetworkClient)

    This is a hook that is invoked when the client is started.

    StartClient has multiple signatures, but they all cause this hook to be called.

    Declaration
    public override void OnStartClient(NetworkClient client)
    Parameters
    Type Name Description
    NetworkClient client

    The NetworkClient object that was started.

    Overrides
    NetworkManager.OnStartClient(NetworkClient)

    OnStartHost()

    This hook is invoked when a host is started.

    StartHost has multiple signatures, but they all cause this hook to be called.

    Declaration
    public override void OnStartHost()
    Overrides
    NetworkManager.OnStartHost()

    OnStartServer()

    This hook is invoked when a server is started - including when a host is started. StartServer has multiple signatures, but they all cause this hook to be called.

    Declaration
    public override void OnStartServer()
    Overrides
    NetworkManager.OnStartServer()

    OnStopClient()

    This hook is called when a client is stopped.

    Declaration
    public override void OnStopClient()
    Overrides
    NetworkManager.OnStopClient()

    OnStopHost()

    This hook is called when a host is stopped.

    Declaration
    public override void OnStopHost()
    Overrides
    NetworkManager.OnStopHost()

    OnStopServer()

    This hook is called when a server is stopped - including when a host is stopped.

    Declaration
    public override void OnStopServer()
    Overrides
    NetworkManager.OnStopServer()
    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)