Description
Describe the bug
When a NetworkManager is attached to a game object that has a parent (ie. not a root game object in the scene) a warning is raised in the console when entering play mode.
DontDestroyOnLoad only works for root GameObjects or components on root GameObjects.
Although I did not test it, I believe this warning also indicates that the network manager will be destroyed when a scene transition occurs.
It may be a reasonable requirement that network managers are root objects, and it would not be a good user experience to automatically fix this on behalf of the user. But this warning is not actionable and doesn't refer specifically to the issue that is occurring. (The issue for the user to fix is not to worry about DontDestroyOnLoad, but to worry about the placement of the networkmanager in the hierarchy)
To Reproduce
Steps to reproduce the behavior:
- Create an empty scene
- Create a new game object
- Add a network manager component and connect a transport to it
- Create another new game object
- Place the network manager game object as a child of the new game object
- Enter play mode
- Observe the warning that occurs
Expected behavior
Warnings that are raised to the user should clearly describe the problem and how to fix it
Environment (please complete the following information):
- OS: Win10
- Unity Version: 2020.2.7f1
- MLAPI Version: 0.1.0
- MLAPI Commit: ddf9d9b
Additional context
Stack trace
DontDestroyOnLoad only works for root GameObjects or components on root GameObjects. UnityEngine.StackTraceUtility:ExtractStackTrace () MLAPI.NetworkManager:OnEnable () (at Library/PackageCache/com.unity.multiplayer.mlapi@ddf9d9baf8/Runtime/Core/NetworkManager.cs:579)