Version: 5.4 (switch to 5.5b)
  • C#
  • JS

Script language

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


class in UnityEngine.Networking

Suggest a change


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.


Sumbission failed

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





これは、ネットワークシステムによって利用されるネットワーククライアントクラスです。ネットワークサーバーへの接続に使用する NetworkConnection が含まれています。

NetworkClient は接続状態、メッセージハンドラー、接続設定を処理します。一度に多くの処理中の NetworkClient インスタンスがありますが、生成したオブジェクトを使うゲームサーバー (NetworkServer) に接続するのは 1 つのみです。

NetworkClient は内部的な更新のための関数で、トランスポート層からのイベントを処理します。非同期接続のイベント、接続終了イベント、サーバーからのデータなどが含まれます。

NetworkManager には開始したゲームに使用する NetworkClient インスタンスがあります。しかし、 NetworkClient はそれ自体で使用する場合もあります。

Static Variables

activeTrue if a network client is currently active.
allClientsA list of all the active network clients in the current process.


connectionThe NetworkConnection object this client is using.
handlersThe registered network message handlers.
hostTopologyThe host topology that this client is using.
isConnectedThis gives the current connection status of the client.
networkConnectionClassThe class to use when creating new NetworkConnections.
numChannelsThe number of QoS channels currently configured for this client.
serverIpThe IP address of the server that this client is connected to.
serverPortThe port of the server that this client is connected to.


NetworkClient新しい NetworkClient インスタンスを作成します。

Public Functions

ConfigureThis configures the transport layer settings for a client.
ConnectConnect client to a NetworkServer instance.
ConnectWithSimulatorConnect client to a NetworkServer instance with simulated latency and packet loss.
DisconnectDisconnect from server.
GetConnectionStatsRetrieves statistics about the network packets sent on this connection.
GetRTTGets the Return Trip Time for this connection.
GetStatsInGet inbound network statistics for the client.
GetStatsOutGet outbound network statistics for the client.
ReconnectToNewHostThis is used by a client that has lost the connection to the old host, to reconnect to the new host of a game.
RegisterHandlerRegister a handler for a particular message type.
ResetConnectionStatsResets the statistics return by NetworkClient.GetConnectionStats() to zero values.
SendThis sends a network message with a message Id to the server. This message is sent on channel zero, which by default is the reliable channel.
SendByChannelThis sends a network message with a message Id to the server on a specific channel.
SendBytesThis sends the data in an array of bytes to the server that the client is connected to.
SendUnreliableThis sends a network message with a message Id to the server on channel one, which by default is the unreliable channel.
SendWriterThis sends the contents of the NetworkWriter's buffer to the connected server on the specified channel.
SetMaxDelaySet the maximum amount of time that can pass for transmitting the send buffer.
ShutdownShut down a client.
UnregisterHandlerUnregisters a network message handler.

Static Functions

GetTotalConnectionStatsRetrieves statistics about the network packets sent on all connections.
ShutdownAllShuts down all network clients.