Version: 2017.3
public static void Disconnect (int timeout= 200);

Descripción

Cierra todas las conexiones y apaga la interfaz de red.

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 they cannot reconnect to the server as the server thinks they are still connected (after a certain interval the connection will be detected as dropped).

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnGUI() { if (GUILayout.Button("Disconnect")) { Network.Disconnect(); MasterServer.UnregisterHost(); } } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961