Skip to content

NetworkManager raises unspecific warning when game object is not in the root #593

Closed
@becksebenius-unity

Description

@becksebenius-unity

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:

  1. Create an empty scene
  2. Create a new game object
  3. Add a network manager component and connect a transport to it
  4. Create another new game object
  5. Place the network manager game object as a child of the new game object
  6. Enter play mode
  7. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions