用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:network:network

Network 网络

class in UnityEngine

Description 描述

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

Network类是网络实现的核心并提供核心函数。

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.

这个类配置了网络接口和所有网络参数。可以使用它来设置一个服务器或连接到一个服务器并有一些辅助函数来帮助你完成这些功能。获取更多信息请参考Network Manger component reference。

Static Variables 静态变量

connectionsAll connected players.
所有连接的玩家。
connectionTesterIPThe IP address of the connection tester used in Network.TestConnection.
用在Network.TestConnection中的连接测试的IP地址。
connectionTesterPortThe port of the connection tester used in Network.TestConnection.
用在Network.TestConnection中的连接测试的端口。
incomingPasswordSet the password for the server (for incoming connections).
为服务器设置密码(入站连接)。
isClientReturns true if your peer type is client.
如果端点类型是客户端,返回true。
isMessageQueueRunningEnable or disable the processing of network messages.
启用或禁用网络消息处理。
isServerReturns true if your peer type is server.
如果端点类型是服务器,返回true
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.
在ViewID池中获取或设置由服务器分配给客户端ViewID的最小数。
natFacilitatorIPThe IP address of the NAT punchthrough facilitator.
用在Network.TestConnection中的连接测试的IP地址。
natFacilitatorPortThe port of the NAT punchthrough facilitator.
Facilitator NAT穿透的端口。
peerTypeThe status of the peer type, i.e. if it is disconnected, connecting, server or client.
端类型的状态,即disconnected, connecting, server 或 client四种。
playerGet the local NetworkPlayer instance.
获取本地NetworkPlayer实例。
proxyIPThe IP address of the proxy server.
代理服务器的IP地址。
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.
表示是否需要代理支持,在这种情况下,流量通过代理服务器传递。

Static Functions 静态函数

AllocateViewIDQuery for the next available network view ID number and allocate it (reserve).
查询下一个可用的网络视图ID号并分配它(保留)。
CloseConnectionClose the connection to another system.
关闭与其他系统的连接。
ConnectConnect to the specified host (ip or domain name) and server port.
连接到特定的主机(IP或域名)和服务器端口
DestroyDestroy the object associated with this view ID across the network.
跨网络销毁与该viewID相关的物体。
DestroyPlayerObjectsDestroy all the objects based on view IDs belonging to this player.
基于viewID销毁所有属于这个玩家的所有物体。
DisconnectClose all open connections and shuts down the network interface.
关闭所有开放的连接并关闭网络接口。
GetAveragePingThe last average ping time to the given player in milliseconds.
到给定player的最后平均ping时间,以毫秒计。
GetLastPingThe last ping time to the given player in milliseconds.
到给定player的最后ping时间,以毫秒计。
HavePublicAddressCheck if this machine has a public IP address.
检测这台机器是否有一个公网IP地址。
InitializeSecurityInitializes security layer.
初始化安全层
InitializeServerInitialize the server.
初始化服务器
InstantiateNetwork instantiate a prefab.
网络实例化预设。
RemoveRPCsRemove all RPC functions which belong to this player ID.
移除所有属于这个玩家的ID的RPC函数。
RemoveRPCsInGroupRemove all RPC functions which belong to given group number.
移除属于给定组的所有RPC函数。
SetLevelPrefixSet the level prefix which will then be prefixed to all network ViewID numbers.
设置关卡前缀,然后所有网络ViewID数都会使用该前缀。
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.
启用或禁用在特定网络组的信息传输和RPC调用。
TestConnectionTest this machines network connection.
测试这台机器的网络连接。
TestConnectionNATTest the connection specifically for NAT punch-through connectivity.
用于测试特定连接的NAT穿透连接性。

Messages 消息

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.
当一个物体使用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.
每当一个Network.InitializeServer被调用并完成时,在服务器上调用这个函数。
script/unityengine/classes/network/network.txt · 最后更改: 2016/08/02 05:27 (外部编辑)