Search Unity

Network Manager throws InvalidOperationException after build in Unity 5.5.0f3

Discussion in 'Multiplayer' started by gamevanilla, Dec 4, 2016.

  1. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    After upgrading one of my projects to Unity 5.5.0f3, I realized there is a problem with Network Manager. If you have a scene that contains a Network Manager with the Dont Destroy On Load option set to true (which is the default) and generate a build, you will receive the following warning:

    NetworkManager detected a script reload in the editor. This has caused the network to be shut down.
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()


    and the following error:

    InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: NetworkManager. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script.
    UnityEngine.Networking.NetworkManager.InitializeSingleton () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkManager.cs:196)
    UnityEngine.Networking.NetworkManager.UpdateScene () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkManager.cs:729)
    UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:1074)

    This happens after building and, sometimes, after selecting the Network Manager object in the project hierarchy. The resulting build seems to work just fine, though.

    If you set the Dont Destroy On Load option to false, you only receive the warning.

    I isolated this issue in a test project and submitted a bug report (#857876), as I understand this should not happen (it certainly did not happen in previous versions of the engine).
     
  2. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    The QA team has replied to my bug report in just a few hours (which is pretty awesome), confirming this issue is no longer reproducible in 5.6 and the fix should be available in future releases of 5.6 and 5.5 (possibly 5.5.0p1).
     
  3. gamevanilla

    gamevanilla

    Joined:
    Dec 28, 2015
    Posts:
    968
    Unity 5.5.0p1 does indeed fix this error. It still throws the warning sometimes when selecting the Network Manager object in the project hierarchy though.