言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Network.Disconnect

Suggest a change

Success!

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.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public static function Disconnect(timeout: int = 200): void;
public static void Disconnect(int timeout = 200);
public static def Disconnect(timeout as int = 200) as void

Description

接続をすべて閉じてネットワークインタフェースをシャットダウンします

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. Note that if you set the timeout to 0 the network interface will shut down before the disconnect notification can be sent to the remote party. For a client this could mean he cannot reconnect to the server as the server thinks he is still connected (after a certain interval the connection will be detected as dropped).

	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()