diff --git a/Assets/Mirror/Runtime/ClientScene.cs b/Assets/Mirror/Runtime/ClientScene.cs index 71a01ab6a..13a7ae65b 100644 --- a/Assets/Mirror/Runtime/ClientScene.cs +++ b/Assets/Mirror/Runtime/ClientScene.cs @@ -664,7 +664,7 @@ static void OnOwnerMessage(NetworkMessage netMsg) if (NetworkIdentity.spawned.TryGetValue(msg.netId, out NetworkIdentity localObject) && localObject != null) { // this object already exists - localObject.SetConnectionToServer(netMsg.conn); + localObject.connectionToServer = netMsg.conn; localObject.SetLocalPlayer(); InternalAddPlayer(localObject); } @@ -684,7 +684,7 @@ static void CheckForOwner(NetworkIdentity identity) // found owner, turn into a local player // Set isLocalPlayer to true on this NetworkIdentity and trigger OnStartLocalPlayer in all scripts on the same GO - identity.SetConnectionToServer(readyConnection); + identity.connectionToServer = readyConnection; identity.SetLocalPlayer(); if (LogFilter.Debug) { Debug.Log("ClientScene::OnOwnerMessage - player=" + identity.name); } diff --git a/Assets/Mirror/Runtime/LocalClient.cs b/Assets/Mirror/Runtime/LocalClient.cs index 067663b55..d4ba10c1a 100644 --- a/Assets/Mirror/Runtime/LocalClient.cs +++ b/Assets/Mirror/Runtime/LocalClient.cs @@ -55,7 +55,7 @@ internal void AddLocalPlayer(NetworkIdentity localPlayer) { localPlayer.EnableIsClient(); NetworkIdentity.spawned[localPlayer.netId] = localPlayer; - localPlayer.SetConnectionToServer(connection); + localPlayer.connectionToServer = connection; } // there is no SystemOwnerMessage for local client. add to ClientScene here instead ClientScene.InternalAddPlayer(localPlayer); diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index 7c768bc19..873bb45cc 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -46,8 +46,8 @@ public sealed class NetworkIdentity : MonoBehaviour public bool serverOnly { get { return m_ServerOnly; } set { m_ServerOnly = value; } } public bool localPlayerAuthority { get { return m_LocalPlayerAuthority; } set { m_LocalPlayerAuthority = value; } } public NetworkConnection clientAuthorityOwner { get; private set; } - public NetworkConnection connectionToServer { get; private set; } - public NetworkConnection connectionToClient { get; private set; } + public NetworkConnection connectionToServer { get; internal set; } + public NetworkConnection connectionToClient { get; internal set; } // all spawned NetworkIdentities by netId. needed on server and client. public static Dictionary spawned = new Dictionary(); @@ -648,16 +648,6 @@ internal void SetLocalPlayer() } } - internal void SetConnectionToServer(NetworkConnection conn) - { - connectionToServer = conn; - } - - internal void SetConnectionToClient(NetworkConnection conn) - { - connectionToClient = conn; - } - internal void OnNetworkDestroy() { for (int i = 0; m_NetworkBehaviours != null && i < m_NetworkBehaviours.Length; i++) diff --git a/Assets/Mirror/Runtime/NetworkServer.cs b/Assets/Mirror/Runtime/NetworkServer.cs index e05522797..9bf1e86e9 100644 --- a/Assets/Mirror/Runtime/NetworkServer.cs +++ b/Assets/Mirror/Runtime/NetworkServer.cs @@ -524,7 +524,7 @@ internal static bool InternalAddPlayerForConnection(NetworkConnection conn, Game conn.SetPlayerController(identity); // Set the connection on the NetworkIdentity on the server, NetworkIdentity.SetLocalPlayer is not called on the server (it is on clients) - identity.SetConnectionToClient(conn); + identity.connectionToClient = conn; SetClientReady(conn); @@ -613,7 +613,7 @@ internal static bool InternalReplacePlayerForConnection(NetworkConnection conn, conn.SetPlayerController(playerNetworkIdentity); // Set the connection on the NetworkIdentity on the server, NetworkIdentity.SetLocalPlayer is not called on the server (it is on clients) - playerNetworkIdentity.SetConnectionToClient(conn); + playerNetworkIdentity.connectionToClient = conn; //NOTE: DONT set connection ready.