mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: NetworkManager.StopServer/StopClient: avoid NullReferenceException when called in OnApplicationQuit or from tests
This commit is contained in:
parent
425e3131dc
commit
25ece5a0d5
@ -646,7 +646,10 @@ public void StopServer()
|
||||
|
||||
// Get Network Manager out of DDOL before going to offline scene
|
||||
// to avoid collision and let a fresh Network Manager be created.
|
||||
if (gameObject.scene.name == "DontDestroyOnLoad"
|
||||
// IMPORTANT: .gameObject can be null if StopClient is called from
|
||||
// OnApplicationQuit or from tests!
|
||||
if (gameObject != null &&
|
||||
gameObject.scene.name == "DontDestroyOnLoad"
|
||||
&& !string.IsNullOrEmpty(offlineScene)
|
||||
&& SceneManager.GetActiveScene().path != offlineScene)
|
||||
SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetActiveScene());
|
||||
@ -684,7 +687,10 @@ public void StopClient()
|
||||
|
||||
// Get Network Manager out of DDOL before going to offline scene
|
||||
// to avoid collision and let a fresh Network Manager be created.
|
||||
if (gameObject.scene.name == "DontDestroyOnLoad"
|
||||
// IMPORTANT: .gameObject can be null if StopClient is called from
|
||||
// OnApplicationQuit or from tests!
|
||||
if (gameObject != null &&
|
||||
gameObject.scene.name == "DontDestroyOnLoad"
|
||||
&& !string.IsNullOrEmpty(offlineScene)
|
||||
&& SceneManager.GetActiveScene().path != offlineScene)
|
||||
SceneManager.MoveGameObjectToScene(gameObject, SceneManager.GetActiveScene());
|
||||
|
Loading…
Reference in New Issue
Block a user