Force Network Manager to scene root if DDOL (#2936)

This commit is contained in:
MrGadget 2021-09-24 00:52:53 -04:00 committed by GitHub
parent 2d2710f60e
commit 60692f0373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -669,7 +669,13 @@ bool InitializeSingleton()
}
//Debug.Log("NetworkManager created singleton (DontDestroyOnLoad)");
singleton = this;
if (Application.isPlaying) DontDestroyOnLoad(gameObject);
if (Application.isPlaying)
{
// Force the object to scene root, in case user made it a child of something
// in the scene since DDOL is only allowed for scene root objects
transform.SetParent(null);
DontDestroyOnLoad(gameObject);
}
}
else
{