Skip to content

Commit 3e1aef3

Browse files
authored
fix: NetworkManager doesn't destroy itself on multi instance (#765)
1 parent ea30795 commit 3e1aef3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

com.unity.multiplayer.mlapi/Runtime/Core/NetworkManager.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,6 @@ private void Awake()
719719

720720
private void OnEnable()
721721
{
722-
if (Singleton != null && Singleton != this)
723-
{
724-
Destroy(gameObject);
725-
return;
726-
}
727-
728-
SetSingleton();
729-
730722
if (DontDestroy)
731723
{
732724
DontDestroyOnLoad(gameObject);
@@ -736,13 +728,19 @@ private void OnEnable()
736728
{
737729
Application.runInBackground = true;
738730
}
731+
732+
if (Singleton == null)
733+
{
734+
SetSingleton();
735+
}
739736
}
740737

741738
private void OnDestroy()
742739
{
743-
if (Singleton != null && Singleton == this)
740+
Shutdown();
741+
742+
if (Singleton == this)
744743
{
745-
Shutdown();
746744
Singleton = null;
747745
}
748746
}

0 commit comments

Comments
 (0)