public void OnClientDisconnect (Networking.NetworkConnection conn);

Parámetros

connConexión al servidor.

Descripción

Es llamado en los clientes cuando se desconectan de un servidor.

This is called on the client when it disconnects from the server. Override this function to decide what happens when the client disconnects.

//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 OnClientConnectExample : 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!"; } }