UNet Unity Networking - Making it easy
Decided to come up with a simple approach to dealing with networking.
What I want:
I want to be able to send messages to all clients from any client in a static manner from anywhere anytime
What I came up with:
Probably wanna open that in another tab. Note: NetworkHub is my class I’m extending
Basically it consists of a Networking behaviour that:
* A class behaviour that you can spawn 1 of for a player over the network using Unity's UNet * To use it, just extend the base and setup the abstract methods * Gives every player a unique integer ID to identify you by * Gives you a single point to send networking messages to every other client. Can send anything that can be written as a byte[]. * OnPlayerConnected/Disconnected that every client can use (normally only the server gets those events) * You can still use UNet however you want, this just gives you an additional thing you can use
The usage for me is “Send a message, it gets routed based off an ‘type’ to a handler that processes it. This way you could have say a ‘debug handler’ and a ‘play sound handler’ which could do whatever they wanted independently.” It’s generic enough with interfaces though that you can be it less complex than that.
Still have some more stuff to add and optimize, but I’ll likely put this on the Asset Store for a few dollars.
Comments?














