Version: 2017.1

NetworkMigrationManager.ReconnectPlayerForConnection

切换到手册
public bool ReconnectPlayerForConnection (Networking.NetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId);

参数

newConnection 新客户端的连接。
oldPlayer 玩家对象。
oldConnectionId 此客户端在旧主机上的 connectionId。
playerControllerId 重新加入的玩家的 playerControllerId。

返回

bool 如果能够重新加入此玩家,则为 true。

描述

使用重新连接的客户端重新建立一个玩家对象。与 NetworkServer.AddPlayerForConnection() 类似。玩家游戏对象将成为新连接的玩家对象。

使用 OnServerReconnectPlayer 时会默认调用此类。

using UnityEngine;
using UnityEngine.Networking;

class MyMigrationManager : NetworkMigrationManager { protected override void OnServerReconnectPlayer(NetworkConnection newConnection, GameObject oldPlayer, int oldConnectionId, short playerControllerId) { Debug.Log("Reconnecting oldPlayer:" + oldPlayer); ReconnectPlayerForConnection(newConnection, oldPlayer, oldConnectionId, playerControllerId); } }