From 60692f037391ccbf9ac92e448ef8b58f9fdde27b Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Fri, 24 Sep 2021 00:52:53 -0400 Subject: [PATCH] Force Network Manager to scene root if DDOL (#2936) --- Assets/Mirror/Runtime/NetworkManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Runtime/NetworkManager.cs b/Assets/Mirror/Runtime/NetworkManager.cs index 2bcdb4c38..1dc6ea1ee 100644 --- a/Assets/Mirror/Runtime/NetworkManager.cs +++ b/Assets/Mirror/Runtime/NetworkManager.cs @@ -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 {