Version: 2017.3
public static NetworkPeerType peerType ;

描述

对等方类型的状态,即是否断开连接、是否正在连接,是服务器还是客户端。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnGUI() { if (Network.peerType == NetworkPeerType.Disconnected) GUILayout.Label("Not Connected"); else if (Network.peerType == NetworkPeerType.Connecting) GUILayout.Label("Connecting"); else GUILayout.Label("Network started"); } }