Custom NetworkManagerHUD in Unity Networking

So I just tossed out a ton of deprecated Unity 4 networking code and replaced it with Unity 5 code, and I wanted to share it with you guys because the documentation on the official Unity site is a little lacking.

If you looked at the matchmaking docs and used that to implement your own HUD to control the NetworkManager, you would find that the behavior is different from the stock NetworkManagerHUD. This is rather misleading and caused me to waste a significant amount of time.

Ultimately, I looked at the actual code for the NetworkManagerHUD and found the correct functions to call. Strangely, this information is not on the NetworkManager reference page… Quite a large thing to overlook. Instead, look at the NetworkManager script reference page.

The functions that you will want to call if you want to create your own UI for the NetworkManager are the following

LAN Host
NetworkManager.StartHost()
LAN Server Only
NetworkManager.StartServer()
Stop Host
NetworkManager.StopHost()
Enable Matchmaker
NetworkManager.StartMatchmaker()

All of the relevant MatchMaker functions are in NetworkMatch documentation. The catch is, do not run your own callback function like it says in the MatchMaker guide. The code there is not the same as the code in NetworkManagerHUD. Instead, use the callback functions provided already in the NetworkManager. Again, these are missing from the docs.

NetworkManager.OnMatchCreate - pair this with NetworkMatch.CreateMatch
NetworkManager.OnMatchJoined - pair this with NetworkMatch.JoinMatch
NetworkManager.OnMatchList - pair this with NetworkMatch.ListMatches

There you have it, the tools to make your own UI for the NetworkManager.

Recent search terms:

  • networkmanagerhud unity 2017 github
  • unity network manager custom
  • unity custom network hud