diff --git a/Assets/Mirror/Components/NetworkLobbyManager.cs b/Assets/Mirror/Components/NetworkLobbyManager.cs index 29dbd73ed..9f654df60 100644 --- a/Assets/Mirror/Components/NetworkLobbyManager.cs +++ b/Assets/Mirror/Components/NetworkLobbyManager.cs @@ -195,7 +195,7 @@ public override void OnServerDisconnect(NetworkConnection conn) OnLobbyServerDisconnect(conn); } - public override void OnServerAddPlayer(NetworkConnection conn) + public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) { if (SceneManager.GetActiveScene().name != LobbyScene) return; diff --git a/Assets/Mirror/Examples/Lobby/Scripts/NetworkLobbyPlayerExt.cs b/Assets/Mirror/Examples/Lobby/Scripts/NetworkLobbyPlayerExt.cs index 0e452e277..e39b955c4 100644 --- a/Assets/Mirror/Examples/Lobby/Scripts/NetworkLobbyPlayerExt.cs +++ b/Assets/Mirror/Examples/Lobby/Scripts/NetworkLobbyPlayerExt.cs @@ -18,7 +18,7 @@ This demonstrates how to set the parent of the LobbyPlayerPrefab to an arbitrary A similar technique would be used if a full canvas layout UI existed and we wanted to show something more visual for each player in that layout, such as a name, avatar, etc. - Note: LobbyPlayer prefab will be marked DontDestroyOnLoad and carried forward to the game scene. + Note: LobbyPAlayer prefab will be marked DontDestroyOnLoad and carried forward to the game scene. Because of this, NetworkLobbyManager must automatically set the parent to null in ServerChangeScene and OnClientChangeScene. */ diff --git a/Assets/Mirror/Runtime/ClientScene.cs b/Assets/Mirror/Runtime/ClientScene.cs index f5bd252cf..80cd06526 100644 --- a/Assets/Mirror/Runtime/ClientScene.cs +++ b/Assets/Mirror/Runtime/ClientScene.cs @@ -64,7 +64,7 @@ internal static void InternalAddPlayer(NetworkIdentity identity) // use this to implicitly become ready // -> extraMessage can contain character selection, etc. - public static bool AddPlayer(NetworkConnection readyConn, MessageBase extraMessage) + public static bool AddPlayer(NetworkConnection readyConn, byte[] extraData) { // ensure valid ready connection if (readyConn != null) @@ -87,13 +87,10 @@ public static bool AddPlayer(NetworkConnection readyConn, MessageBase extraMessa if (LogFilter.Debug) { Debug.Log("ClientScene.AddPlayer() called with connection [" + readyConnection + "]"); } - AddPlayerMessage msg = new AddPlayerMessage(); - if (extraMessage != null) + AddPlayerMessage msg = new AddPlayerMessage() { - NetworkWriter writer = new NetworkWriter(); - extraMessage.Serialize(writer); - msg.value = writer.ToArray(); - } + value = extraData + }; readyConnection.Send(msg); return true; } diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 5fa53e418..d15f32be3 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -552,21 +552,7 @@ internal void OnServerAddPlayerMessageInternal(NetworkConnection conn, AddPlayer { if (LogFilter.Debug) { Debug.Log("NetworkManager.OnServerAddPlayerMessageInternal"); } - if (msg.value != null && msg.value.Length > 0) - { - // convert payload to extra message and call OnServerAddPlayer - // (usually for character selection information) - NetworkMessage extraMessage = new NetworkMessage - { - reader = new NetworkReader(msg.value), - conn = conn - }; - OnServerAddPlayer(conn, extraMessage); - } - else - { - OnServerAddPlayer(conn); - } + OnServerAddPlayer(conn, msg); } internal void OnServerRemovePlayerMessageInternal(NetworkConnection conn, RemovePlayerMessage msg) @@ -661,12 +647,7 @@ public virtual void OnServerReady(NetworkConnection conn) NetworkServer.SetClientReady(conn); } - public virtual void OnServerAddPlayer(NetworkConnection conn, NetworkMessage extraMessage) - { - OnServerAddPlayerInternal(conn); - } - - public virtual void OnServerAddPlayer(NetworkConnection conn) + public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) { OnServerAddPlayerInternal(conn); }