- AllocateViewID
- CloseConnection
- connections
- connectionTesterIP
- connectionTesterPort
- Connect
- DestroyPlayerObjects
- Destroy
- Disconnect
- GetAveragePing
- GetLastPing
- HavePublicAddress
- incomingPassword
- InitializeSecurity
- InitializeServer
- Instantiate
- isClient
- isMessageQueueRunning
- isServer
- logLevel
- maxConnections
- minimumAllocatableViewIDs
- natFacilitatorIP
- natFacilitatorPort
- OnConnectedToServer
- OnDisconnectedFromServer
- OnFailedToConnectToM...
- OnFailedToConnect
- OnNetworkInstantiate
- OnPlayerConnected
- OnPlayerDisconnected
- OnSerializeNetworkView
- OnServerInitialized
- peerType
- player
- proxyIP
- proxyPassword
- proxyPort
- RemoveRPCsInGroup
- RemoveRPCs
- sendRate
- SetLevelPrefix
- SetReceivingEnabled
- SetSendingEnabled
- TestConnectionNAT
- TestConnection
- time
- useProxy
Network.Connect 连接
static function Connect (IP : string, remotePort : int, password : string = "") : NetworkConnectionError
Description描述
Connect to the specified host (ip or domain name) and server port.
连接到特定的主机(IP或域名)和服务器端口。
The parameters are the IP address of the host. Either a dotted IP address or a domain name. remotePort, which specifies the port on the remote machine to connect to. password, which is an optional password for the server. The password has to match the Network.incomingPassword set on the server.
参数是主机的IP地址,无论是带点的IP地址或域名。remotePort,指定连接到远端机器的端口。password是一个可选的用于服务器的密码。这个密码必须匹配Network.incomingPassword在服务器的设置。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void ConnectToServer() {
Network.Connect("127.0.0.1", 25000);
}
}
function ConnectToServer () {
Network.Connect("127.0.0.1", 25000);
}
• static function Connect (IPs : string[], remotePort : int, password : string = "") : NetworkConnectionError
Description描述
This function is exactly like Network.Connect but can accept an array of IP addresses.
该函数与Network.Connect类似,但是可以接受一个IP地址数组。
It can be used when the host information from a master server returns multiple internal IP addresses, then the IP data structure can be passed directly into this connect function. It actually connects to the first IP which responds to a ping (i.e. is connectable).
它可以用于,当从一个主服务器的主机信息返回多个内部IP地址时,IP数据结构可以被直接传入这个函数。它实际连接到相应ping的第一个IP(可连接)。
• static function Connect (GUID : string, password : string = "") : NetworkConnectionError
Description描述
Connect to a server GUID. NAT punchthrough can only be performed this way.
连接到一个服务器GUID,NAT穿透只能在这种方式执行。
The host GUID value is exposed locally through the NetworkPlayer structure. The master server also provides this in the HostData structure.
主机的GUID值,通过NetworkPlayer结构暴露在本地。主服务器还提供这个在HostData结构。
• static function Connect (hostData : HostData, password : string = "") : NetworkConnectionError
Description描述
Connect to the host represented by a HostData structure returned by the Master Server.
连接到主机,通过主服务器由一个HostData结构返回。