diff --git a/Assets/Mirror/Components/NetworkRoomManager.cs b/Assets/Mirror/Components/NetworkRoomManager.cs index a97f8c936..69627a70d 100644 --- a/Assets/Mirror/Components/NetworkRoomManager.cs +++ b/Assets/Mirror/Components/NetworkRoomManager.cs @@ -261,7 +261,7 @@ public override void OnServerDisconnect(NetworkConnection conn) /// /// Connection of the client /// - public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) + public override void OnServerAddPlayer(NetworkConnection conn) { if (SceneManager.GetActiveScene().name != RoomScene) return; diff --git a/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs b/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs index 71ba09ea3..a8869ff5d 100644 --- a/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs +++ b/Assets/Mirror/Examples/Pong/Scripts/NetworkManagerPong.cs @@ -10,7 +10,7 @@ public class NetworkManagerPong : NetworkManager public Transform rightRacketSpawn; GameObject ball; - public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) + public override void OnServerAddPlayer(NetworkConnection conn) { // add player at correct spawn position Transform start = numPlayers == 0 ? leftRacketSpawn : rightRacketSpawn; diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 4ad5da3c6..ccfbefc15 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -872,7 +872,9 @@ void OnServerAddPlayerInternal(NetworkConnection conn, AddPlayerMessage extraMes return; } +#pragma warning disable CS0618 // Type or member is obsolete OnServerAddPlayer(conn, extraMessage); +#pragma warning restore CS0618 // Type or member is obsolete } void OnServerRemovePlayerMessageInternal(NetworkConnection conn, RemovePlayerMessage msg) @@ -1003,13 +1005,24 @@ public virtual void OnServerReady(NetworkConnection conn) NetworkServer.SetClientReady(conn); } + /// + /// Obsolete: Override instead. + /// See Custom Players for details. + /// + /// Connection from client. + /// An extra message object passed for the new player. + [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Override OnServerAddPlayer(NetworkConnection conn) instead. See https://mirror-networking.com/docs/Guides/GameObjects/SpawnPlayerCustom.html for details.")] + public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) + { + OnServerAddPlayer(conn); + } + /// /// Called on the server when a client adds a new player with ClientScene.AddPlayer. /// The default implementation for this function creates a new player object from the playerPrefab. /// /// Connection from client. - /// An extra message object passed for the new player. - public virtual void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) + public virtual void OnServerAddPlayer(NetworkConnection conn) { Transform startPos = GetStartPosition(); GameObject player = startPos != null