MonoBehaviour
- Awake
- CancelInvoke
- FixedUpdate
- InvokeRepeating
- Invoke
- IsInvoking
- LateUpdate
- OnApplicationFocus
- OnApplicationPause
- OnApplicationQuit
- OnBecameInvisible
- OnBecameVisible
- OnCollisionEnter
- OnCollisionExit
- OnCollisionStay
- OnConnectedToServer
- OnControllerColliderHit
- OnDestroy
- OnDisable
- OnDisconnectedFromServer
- OnDrawGizmosSelected
- OnDrawGizmos
- OnEnable
- OnFailedToConnectToM...
- OnFailedToConnect
- OnGUI
- OnJointBreak
- OnLevelWasLoaded
- OnMasterServerEvent
- OnMouseDown
- OnMouseDrag
- OnMouseEnter
- OnMouseExit
- OnMouseOver
- OnMouseUpAsButton
- OnMouseUp
- OnNetworkInstantiate
- OnParticleCollision
- OnPlayerConnected
- OnPlayerDisconnected
- OnPostRender
- OnPreCull
- OnPreRender
- OnRenderImage
- OnRenderObject
- OnSerializeNetworkView
- OnServerInitialized
- OnTriggerEnter
- OnTriggerExit
- OnTriggerStay
- OnWillRenderObject
- Reset
- StartCoroutine
- Start
- StopAllCoroutines
- StopCoroutine
- Update
- useGUILayout
MonoBehaviour.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年1月2日 Sunday 18:12