断开所有当前连接的客户端。
此方法只能在服务器上调用。客户端将收到断开连接消息。
using UnityEngine; using UnityEngine.Networking;
public class Example : MonoBehaviour { enum GameState { kInit, kStart } GameState state;
public void Update() { if (state != GameState.kInit) { if (Input.GetKey(KeyCode.Escape)) { Debug.Log("Disconnecting all!"); NetworkServer.DisconnectAll(); Application.LoadLevel("empty"); state = GameState.kStart; } } } }