LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

NetworkIdentity.connectionToClient

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public var connectionToClient: Networking.NetworkConnection;
public Networking.NetworkConnection connectionToClient;

Description

The connection associated with this NetworkIdentity. This is only valid for player objects on the server.

Use it to return details such as the connection’s identity, IP address and ready status.

no example available in JavaScript
//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); } }

Did you find this page useful? Please give it a rating: