Arguments for multiple methods in NetworkManager have changed

You will find after your upgrade that your NetworkManager.cs script claims that Unity claims that you can no longer override methods OnServerConnect, OnServerDisconnect, and OnServerAddPlayer – this is actually not true, but the signature for these methods has changed. They now require an object of type NetworkConnectionToClient as their argument (instead of NetworkConnection) – so your override method lines should look similar to this now:

public override void OnServerAddPlayer(NetworkConnectionToClient  conn)
{
  // do stuff
}

*If you are interested in how I came to that solution, I used the inspector in my editor to dive into Mirror’s code and looked the the original parent NetworkManager.cs (in Mirror/Runtime/NetworkManager.cs) and I saw the new method signatures there. Note that this whole method is obsolete, but it works still :slight_smile: *

For an official solution on how to fix this – check this other thread NetworkManager.OnClientConnect is obsolete

Also, as a side note: As of April 2022, Telepathy is no longer deprecated. It (and KCP) are both supported as of Mirror 66.0.9. I can only assume that vis2k (the author of Mirror) deprecated and then revived it since he uses it for his MMORPG assets.

3 Likes

Thank you for sharing this.

Thanks so much! I was stuck hard on this!

1 Like

Privacy & Terms