Select your preferred scripting language. All code snippets will be displayed in this language.
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseClose all open connections and shuts down the network interface.
The timeout
parameter indicates how much time in milliseconds the network interface gets to signal to others that it is disconnecting.
The network state, like security and password, is also reset.
function OnGUI() { if (GUILayout.Button ("Disconnect")) { Network.Disconnect(); MasterServer.UnregisterHost(); } }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { void OnGUI() { if (GUILayout.Button("Disconnect")) { Network.Disconnect(); MasterServer.UnregisterHost(); } } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): def OnGUI() as void: if GUILayout.Button('Disconnect'): Network.Disconnect() MasterServer.UnregisterHost()