Version: 5.3 (switch to 5.4b)
ЯзыкEnglish
  • C#
  • JS

Язык программирования

Выберите подходящий для вас язык программирования. Все примеры кода будут представлены на выбранном языке.

Network

class in UnityEngine

Предложить изменения

Успех!

Благодарим вас за то, что вы помогаете нам улучшить качество документации по Unity. Однако, мы не можем принять любой перевод. Мы проверяем каждый предложенный вами вариант перевода и принимаем его только если он соответствует оригиналу.

Закрыть

Ошибка внесения изменений

По определённым причинам предложенный вами перевод не может быть принят. Пожалуйста <a>попробуйте снова</a> через пару минут. И выражаем вам свою благодарность за то, что вы уделяете время, чтобы улучшить документацию по Unity.

Закрыть

Отменить

Руководство

Описание

The network class is at the heart of the network implementation and provides the core functions.

This class configures the network interface and all the network parameters. You use it to set up a server or connect to one and have a row of helper functions to help you with those tasks. For more information on what is exposed in the editor see the Network Manger component reference.

Статические переменные

connectionsAll connected players.
connectionTesterIPThe IP address of the connection tester used in Network.TestConnection.
connectionTesterPortThe port of the connection tester used in Network.TestConnection.
incomingPasswordSet the password for the server (for incoming connections).
isClientReturns true if your peer type is client.
isMessageQueueRunningEnable or disable the processing of network messages.
isServerReturns true if your peer type is server.
logLevelSet the log level for network messages (default is Off).
maxConnectionsSet the maximum amount of connections/players allowed.
minimumAllocatableViewIDsGet or set the minimum number of ViewID numbers in the ViewID pool given to clients by the server.
natFacilitatorIPThe IP address of the NAT punchthrough facilitator.
natFacilitatorPortThe port of the NAT punchthrough facilitator.
peerTypeThe status of the peer type, i.e. if it is disconnected, connecting, server or client.
playerGet the local NetworkPlayer instance.
proxyIPThe IP address of the proxy server.
proxyPasswordSet the proxy server password.
proxyPortThe port of the proxy server.
sendRateThe default send rate of network updates for all Network Views.
timeGet the current network time (seconds).
useProxyIndicate if proxy support is needed, in which case traffic is relayed through the proxy server.

Статические функции

AllocateViewIDQuery for the next available network view ID number and allocate it (reserve).
CloseConnectionClose the connection to another system.
ConnectConnect to the specified host (ip or domain name) and server port.
DestroyDestroy the object associated with this view ID across the network.
DestroyPlayerObjectsDestroy all the objects based on view IDs belonging to this player.
DisconnectClose all open connections and shuts down the network interface.
GetAveragePingThe last average ping time to the given player in milliseconds.
GetLastPingThe last ping time to the given player in milliseconds.
HavePublicAddressCheck if this machine has a public IP address.
InitializeSecurityInitializes security layer.
InitializeServerInitialize the server.
InstantiateNetwork instantiate a prefab.
RemoveRPCsRemove all RPC functions which belong to this player ID.
RemoveRPCsInGroupRemove all RPC functions which belong to given group number.
SetLevelPrefixSet the level prefix which will then be prefixed to all network ViewID numbers.
SetReceivingEnabledEnable or disables the reception of messages in a specific group number from a specific player.
SetSendingEnabledEnables or disables transmission of messages and RPC calls on a specific network group number.
TestConnectionTest this machines network connection.
TestConnectionNATTest the connection specifically for NAT punch-through connectivity.

Сообщения

OnConnectedToServerCalled on the client when you have successfully connected to a server.
OnDisconnectedFromServerCalled on client during disconnection from server, but also on the server when the connection has disconnected.
OnFailedToConnectCalled on the client when a connection attempt fails for some reason.
OnNetworkInstantiateCalled on objects which have been network instantiated with Network.Instantiate.
OnPlayerConnectedCalled on the server whenever a new player has successfully connected.
OnPlayerDisconnectedCalled on the server whenever a player is disconnected from the server.
OnSerializeNetworkViewUsed to customize synchronization of variables in a script watched by a network view.
OnServerInitializedCalled on the server whenever a Network.InitializeServer was invoked and has completed.