conn | 准备就绪的客户端连接。 |
表明客户端连接已准备好进入游戏。
例如,这可以是当客户端进入正在进行的游戏和已完成当前场景的加载时。服务器应该使用适当的处理程序(例如,该处理程序可实例化玩家对象)响应 SYSTEM_READY 事件。
function Start() { NetworkServer.Instance.RegisterHandler(MsgType.SYSTEM_READY, OnPlayerReadyMessage); }
// On the client side function OnLevelWasLoaded() { Debug.Log("Finished loading " + Application.loadedLevelName); NetworkClient.Instance.Ready(); }
// On the server side function OnPlayerReadyMessage(conn : NetworkConnection, reader : NetworkReader) { // create the player object on the server GameObject thePlayer = SpawnPlayer(Vector3.zero, "player");
// This spawns the new player on all clients NetworkServer.Instance.PlayerIsReady(conn, conn.player, "player"); }