From abf5cdcf36574a00995f5c229ebcbc41d0286546 Mon Sep 17 00:00:00 2001 From: MrGadget Date: Tue, 17 Dec 2019 04:16:14 -0500 Subject: [PATCH] feat: Add roomPlayer parameter to OnRoomServerCreateGamePlayer (#1317) * Adds roomPlayer parameter to OnRoomServerCreateGamePlayer * fixed template --- Assets/Mirror/Components/NetworkRoomManager.cs | 16 +++++++++++++++- ...ork Room Manager-NewNetworkRoomManager.cs.txt | 5 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Components/NetworkRoomManager.cs b/Assets/Mirror/Components/NetworkRoomManager.cs index 296124fea..3d58db537 100644 --- a/Assets/Mirror/Components/NetworkRoomManager.cs +++ b/Assets/Mirror/Components/NetworkRoomManager.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using UnityEngine; using UnityEngine.SceneManagement; @@ -145,7 +147,7 @@ void SceneLoadedForPlayer(NetworkConnection conn, GameObject roomPlayer) return; } - GameObject gamePlayer = OnRoomServerCreateGamePlayer(conn); + GameObject gamePlayer = OnRoomServerCreateGamePlayer(conn, roomPlayer); if (gamePlayer == null) { // get start position from base class @@ -518,7 +520,19 @@ public virtual GameObject OnRoomServerCreateRoomPlayer(NetworkConnection conn) /// By default the gamePlayerPrefab is used to create the game-player, but this function allows that behaviour to be customized. The object returned from the function will be used to replace the room-player on the connection. /// /// The connection the player object is for. + /// The room player object for this connection. /// A new GamePlayer object. + public virtual GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn, GameObject roomPlayer) + { + return null; + } + + /// + /// Obsolete: Use instead. + /// + /// The connection the player object is for. + /// A new GamePlayer object. + [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Use OnRoomServerCreateGamePlayer instead")] public virtual GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn) { return null; diff --git a/Assets/ScriptTemplates/53-Mirror__Network Room Manager-NewNetworkRoomManager.cs.txt b/Assets/ScriptTemplates/53-Mirror__Network Room Manager-NewNetworkRoomManager.cs.txt index 7b172caee..cf0476e8a 100644 --- a/Assets/ScriptTemplates/53-Mirror__Network Room Manager-NewNetworkRoomManager.cs.txt +++ b/Assets/ScriptTemplates/53-Mirror__Network Room Manager-NewNetworkRoomManager.cs.txt @@ -69,10 +69,11 @@ public class #SCRIPTNAME# : NetworkRoomManager /// By default the gamePlayerPrefab is used to create the game-player, but this function allows that behaviour to be customized. The object returned from the function will be used to replace the room-player on the connection. /// /// The connection the player object is for. + /// The room player object for this connection. /// A new GamePlayer object. - public override GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn) + public override GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn, GameObject roomPlayer) { - return base.OnRoomServerCreateGamePlayer(conn); + return base.OnRoomServerCreateGamePlayer(conn, roomPlayer); } ///