Search Unity

NetworkTransport.Init() problems with the editor?

Discussion in 'Multiplayer' started by ivan-santiago, Jan 21, 2016.

  1. ivan-santiago

    ivan-santiago

    Joined:
    Jan 21, 2016
    Posts:
    6
    Hello everyone.
    I have this custom NetworkDiscovery class based directly on the one offered by "aabramychev" here: http://forum.unity3d.com/threads/how-should-i-use-local-discovery-with-networktransport.323525/

    Until today it has been working perfectly, but this morning I updated Unity to 5.3.1f1, and after that to 5.3.1p3. Since then, everytime that I call NetworkTransport.Init() in my custom NetworkDiscovery, I get the following warning when trying to play from the Editor:
    "NetworkManager detected a script reload in the editor. This has caused the network to be shut down. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()"
    Because of this, a lot of things stop working properly.

    I have to say that this is only happening when trying to play from the Editor, not in the built executable game.

    What drives me crazy is: 1) Only in the editor. 2) From the update of this morning.

    Any help?

    Many thanks in advance.
    Regards,
    Iván.
     
  2. ivan-santiago

    ivan-santiago

    Joined:
    Jan 21, 2016
    Posts:
    6
    Well, I downgraded to 5.3.0f4 and it is working correctly again. Not sure if I should report it as a bug.
     
  3. webgovernor

    webgovernor

    Joined:
    Feb 10, 2013
    Posts:
    18
    Same problem here. Not only does the warning appear, but it leads to different behavior. For example, in the editor OnLobbyStop client is called an extra time (if using NetworkLobbyManager), which is problematic if you have a scene change in that hook.

    One might do:

    Code (csharp):
    1.  
    2. void KillNetworkAndGoToScores() {
    3.     Destroy(NetManager.Instance.gameObject);
    4.     NetManager.Shutdown();
    5.     SceneManager.LoadScene("Scores");
    6. }
    7.  
    However, that, for me, triggers the "reload" warning in the editor only, which causes an additional call to the StopClient hooks in the network manager.

    I've spent many hours troubleshooting this exact issue.
     
  4. Severos

    Severos

    Joined:
    Oct 2, 2015
    Posts:
    181
    I'm actually having same problem with my project, when I run the server it works perfectly, but when running a client it doesn't want to work at all unless I build and run the build, which is pretty much super hard to debug and trace errors like that.
     
  5. tapticc

    tapticc

    Joined:
    Jan 16, 2014
    Posts:
    379
    Hi I had this problem , started yesterday randomly and I don't know what I did different exactly, but I think I may have added a script which derived from NetworkBehaviour and added this to a game object in the scene. I should have added the game object to the scene AFTER connecting to a game rather than in the scene itself. Changing the timing of when the game object containing a script which derived from NetworkBehaviour fixed the issue for me, hope this helps
     
  6. i_am_seed

    i_am_seed

    Joined:
    Dec 31, 2015
    Posts:
    1
    Any new info on this? Struggling with the same issue.
     
  7. ivan-santiago

    ivan-santiago

    Joined:
    Jan 21, 2016
    Posts:
    6
    As I have said, I went back to 5.3.0f4 and is working fine. I will try 5.3.2 as soon as possible this week and will check if this is still happening.
     
  8. Lofar42

    Lofar42

    Joined:
    Oct 11, 2014
    Posts:
    12
  9. ivan-santiago

    ivan-santiago

    Joined:
    Jan 21, 2016
    Posts:
    6
    Nope. Today I even downloaded the last 5.3.4p1 patch, and still nothing.
     
  10. Lofar42

    Lofar42

    Joined:
    Oct 11, 2014
    Posts:
    12
    Damn. I wonder if the Unity team even knows about this...
     
  11. Lofar42

    Lofar42

    Joined:
    Oct 11, 2014
    Posts:
    12
    @ivan.santiago

    Hey man, so I've had other issues with joining games and stuff so I've been trying loads of stuff. I stumbled across something which actually fixes this for me.

    So i eventually hit this thread: http://forum.unity3d.com/threads/unet-scene-objects-not-spawning-w-custom-networkmanager.369236/

    which took me to this bug: https://issuetracker.unity3d.com/is...ethod-breaks-networkmanager-if-loading-scenes

    which made me paste this:

    Code (CSharp):
    1.  
    2. System.Type type = typeof(UnityEngine.Networking.NetworkManager);
    3. var baseMethod = type.GetMethod("Awake", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
    4. if (baseMethod != null) baseMethod.Invoke(this, null);
    5.        
    where I implement Awake() on my custom networkmanager.

    Now suddenly I don't get that original error anymore.

    Hope it helps!
     
    mdrunk likes this.
  12. DoritoDog

    DoritoDog

    Joined:
    Feb 20, 2016
    Posts:
    7
    For me the problem happened when I called "Initialize" or "StartAsClient" on the NetworkDiscovery right at start. The solution was just to wait a second and then call those methods.
     
  13. mdrunk

    mdrunk

    Joined:
    Apr 26, 2014
    Posts:
    11
    lifesaver