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.

timeout参数表示网络接口在未收到信号的情况下,多长时间会断开。网络状态,如安全和密码,也会被重置。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnGUI() {
		if (GUILayout.Button("Disconnect")) {
			Network.Disconnect();
			MasterServer.UnregisterHost();
		}
	}
}
function OnGUI() {
	if (GUILayout.Button ("Disconnect")) {
		Network.Disconnect();
		MasterServer.UnregisterHost();
	}
}
Page last updated: 2011-4-2