From 6e0c4a66d85e7a7b4be32546211d45dd76c44aea Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Wed, 10 Jan 2024 04:16:47 -0500 Subject: [PATCH] fix(NetworkManager): Prevent client from calling ServerChangeScene (#3729) - Throws error if server isn't active - allows for changing to offline scene regardless --- Assets/Mirror/Core/NetworkManager.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index f5e5d6121..150daccb4 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -850,6 +850,14 @@ public virtual void ServerChangeScene(string newSceneName) return; } + // Throw error if called from client + // Allow changing scene while stopping the server + if (!NetworkServer.active && newSceneName != offlineScene) + { + Debug.LogError("ServerChangeScene can only be called on an active server."); + return; + } + // Debug.Log($"ServerChangeScene {newSceneName}"); NetworkServer.SetAllClientsNotReady(); networkSceneName = newSceneName;