Network.Disconnect Manual     Reference     Scripting  
Scripting > Runtime Classes > Network
Network.Disconnect

static function Disconnect (timeout : int = 200) : void

Description

Close all open connections and shuts down the network interface.

The timeout parameter indicates how much time the network interface gets to signal to others that it is disconnecting. The network state, like security and password, is also reset.

JavaScripts
function OnGUI() {
if (GUILayout.Button ("Disconnect")) {
Network.Disconnect();
MasterServer.UnregisterHost();
}
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void OnGUI() {
if (GUILayout.Button("Disconnect")) {
Network.Disconnect();
MasterServer.UnregisterHost();
}
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def OnGUI():
if GUILayout.Button('Disconnect'):
Network.Disconnect()
MasterServer.UnregisterHost()