Network
- 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.OnPlayerConnected 当玩家连接
function OnPlayerConnected (player : NetworkPlayer) : void
Description描述
Called on the server whenever a new player has successfully connected.
每当一个新玩家成功连接时,在服务器上调用这个函数。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
private int playerCount = 0;
void OnPlayerConnected(NetworkPlayer player) {
Debug.Log("Player " + playerCount++ + " connected from " + player.ipAddress + ":" + player.port);
}
}
private var playerCount: int = 0;
function OnPlayerConnected(player: NetworkPlayer) {
Debug.Log("Player " + playerCount++ +
" connected from " + player.ipAddress +
":" + player.port);
// Populate a data structure with player information ...
//用玩家信息构建一个数据结构
}
最后修改:2011年4月1日 Friday 20:37