The NetworkManagerHUD is a good example of how to use the match maker system, including callbacks, and how to drive the NetworkManger from a UI. The NetworkManagerHUD doesnt use any internal functionality, just the public APIs. (this was posted to the beta forum earlier. reposting here).
Just add all the GUI bits that would usually be GUI buttons etc. and create new UI buttons and text fields by using 'using UnityEngine.UI'
This doesn't work on 5.4, api is changed. Can you give the updated version or is there a detailed info about how to write custom network manager, matchmaking system and it's hud? Thanks
@hakankaraduman This may help some. http://forum.unity3d.com/threads/docs-for-the-5-4-lobby-is-totally-broken.395938/#post-2584542
Unity 5.4 doens't support the scipt like this anymore. Any chance to get the sourcecode to the new NetworkManagerHUD?
Check out Unity's Networking Bitbucket: https://bitbucket.org/Unity-Technol...gerHUD.cs?at=5.4&fileviewer=file-view-default
seanr, I found a bug in your code. if (NetworkServer.active && NetworkClient.active) { if (Input.GetKeyDown(KeyCode.X)) { manager.StopHost(); } } When connected as a client, it still says "Stop (X)", however, pressing X does not disconnect because the above code checks for both client and server being enabled. It should probably replaced with "NetworkServer.active || NetworkClient.active" as it is in the OnGUI method: if (NetworkServer.active || NetworkClient.active) { if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop (X)")) { manager.StopHost(); } ypos += spacing; }
Which parts of the NetworkManager class are free? I know Matchmaker costs money, but what about StartHost / StopHost, and that general namespace? Not asking because I'm a cheapskate, but I'm doing a game for a client (as in, other person, not as in networking) and fees aren't an option for me for this. And ditto previous poster; OnGUI is antiquated and I'm surprised tutorial examples are still using it, though I suppose making prefabs and passing them around isn't easy.
Anyone have an idea why Unity wouldnt just add a 'size' field, rather than us all having to write a custom UI?
Hi there, thanks for this insightful comment. Its helped me a bit but I am still struggling. Would you be kind enough to post a working example for me to work through and intergrate into my basic game please? I am half way through making a 2 player racing game but the online setup i have requires the user to put in their external IP and set up their own port forwarding
Okay, what about NetworkDiscovery? I'm guessing...well, hoping that's free. That's the only way I can implement free LAN-based multiplayer functionality without forcing everyone to type in the host's IP address.
I hope so too. But because I am very new to networking in general its proving to be a real minefield of information
Thank you for posting this! I will read through now and try to inwardly digest it. Please can you help me with a quick description exactly what that script is there to do? Thanks so much!!! EDIT: Sorry I just seen the 'Overview' lol. I will read through that also. I am really hoping this is for what I need it to be
THANK YOU VERY MUCH!! I have not yet worked through your code so I cannot yet say it has helped me (yet!) , but I defintely think making my own netmanager HUD will help me understand more about the network manager in total. ONE THING: I have noticed straight off the bat (just by skimreading the code) that your lines: netManager.networkAddress = "192.168.11.101"; netManager.networkPort = 7777; Them lines seem to input the address and port directly to the network manager -- but how would this make it so that the user didnt have to input the IP/port (and also forward the port)?? what if the user was on IP 192.168.0.10 and port was 7778? Also, where are 'ButHostTxt' and 'hostID' declared? I get error "..does not exist in current context"
Excellent , thank you . That was how i understood it. Its not quite what I was originally after, but an yway to get an online game functioning is what i was needing. I'm now working on some other stuff to learn, but soon will go back to the multiplayer games i started and will use your code. Thanks again
Hey! I'm very new to network programming with Unity and have a few questions regarding your approach. I managed to get it working (have a server and clients connecting to said server), however there doesn't seem to be a callback that is successfully called when a client chooses to disconnect from the server (via netClient.Disconnect(). I thought that DisconnectRequest in ClientController would be called, but it doesn't seem to be (if I'm the client at least). I'm also wondering if there is an alternative to hard-coding the IP address you want to connect to, like some sort of way to scan for open servers on your network? I was trying to use the built in tools but I want to have more control as I'm not really creating a typical "multiplayer game." Thanks!
Hi @JWLewis777, I was trying to use a bit of your code in my application and for some reason, I get an error saying that the NetworkManager does not have a definition of networkAdress, networkPort, neither the StartClient(). I defined the network manager in the same way as you did, and also have enabled the UnityEngine.Networking. Any idea what could be going wrong? UPDATE: Found the problem... I had defined a "NetworkManager" class in another script inside the same project which screwed up things...
Hi @JWLewis777, I attached the server script to a game object and created the network manager game object and attached the "network manager" component that one can find in the network list. When I run it, I get the output "NullReferenceException: object reference not set to an instance of an object" when I call any "netManager.XYZ" step. I added the network manager game object as the "netManager" in the server script game object but I get the same output error. Any ideas of what I could be doing wrong?