Version: 2017.3

NetworkIdentity.connectionToClient

切换到手册
public Networking.NetworkConnection connectionToClient ;

描述

与此 NetworkIdentity 关联的连接。此属性只对服务器上的玩家对象有效。

用于返回连接的身份、IP 地址和就绪状态等详细信息。

//For this example to work, attach a NetworkIdentity component to your GameObject.
//Make sure your Scene has a NetworkManager and NetworkManagerHUD
//Attach this script to the GameObject, and it outputs the connection of your GameObject to the console.

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking;

public class NetworkIdentityNetID : MonoBehaviour { NetworkIdentity m_Identity; //This is a TextMesh component that you attach to the child of the NetworkIdentity GameObject

void Start() { //Fetch the NetworkIdentity component of the GameObject m_Identity = GetComponent<NetworkIdentity>();

//Output to the console the connection associated with this NetworkIdentity Debug.Log("Connection : " + m_Identity.connectionToClient); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961