• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Sgt_Gemini · Dec 19, 2017 at 05:23 PM · networkingcustommanagerlobbycustom class

How to create a custom network lobby manager with unet?

I had a really hard time creating a custom network manager because the documentation for it was either hard to find or not existing at all.

Since this community has given so much to me, I want to give something back.

Below you will find a quick guide for creating your own custom network manager and network lobby manager!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Sgt_Gemini · Dec 19, 2017 at 06:25 PM

Creating a Custom Network Manager

If your game has a lobby you should use the options for NetworkLobbyManager. If not, you can use the normal NetworkManager.


The Steps to freedom!

  • 1: Start by creating a new C# script. You can call it "CustomNetworkManager" or "CustomNetworkLobbyManager".

  • 2: Now change the class type from "MonoBehavior" to "NetworkManager" or "NetworkLobbyManager" depending on your needs.

  • 3: Add the following statements in the beginning of your script: "using UnityEngine.Networking".

  • 4: In your hierarchy, create a new empty gameobject. Rename it to whatever you called your network manager script.

  • 5: Add your custom network manager script to the empty gameobject.

  • 6: Add a Network Manager HUD component to your gameobject (if you don't have your own HUD).

  • 7: Make sure you don't have any other network managers running. Your custom network manager will do exactly the same as the normal network managers.

  • 8: Now you have access to the specific methods of the network manager. Remember to make sure you add the word "override" to your method and be aware that this will stop the normal method from working. This means that if you override a method you have to make sure to add whatever that method did in your own version.


Note: Your custom network manager should be added to the first scene that runs, just like a normal network manager.



A few examples

You will ofcourse have to add methods to your custom network manager (not random scripts) for them to work.


This is how to setup the script

 using UnityEngine.Networking;
     
 public class CustomNetworkLobbyManager : NetworkLobbyManager {
 // Your code here
 }  


OnServerAddPlayer

 public override void OnServerAddPlayer (NetworkConnection conn, short playerControllerId) {
 // your code here
 }


OnServerDisconnect

 public override void OnServerDisconnect (NetworkConnection conn) {
 // Your code here
 }


Here you can see the methods
NetworkManager
NetworkLobbyManager



Final notes

I am by no means an expert on UNET. If you find any mistakes in this guide or have any inputs that you feel should be in here please comment and I will fix or add it!
Best of luck with your networked project! :)


Gemini
Warrior Games

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ShardulMane · Jan 31, 2018 at 09:35 AM 0
Share

Thanx man...

avatar image Nizamutdinov · Nov 18, 2018 at 04:54 PM 0
Share

Thank you, man :) you helped me too much

avatar image
0

Answer by DoritoDog · Oct 10, 2019 at 05:09 AM

If you also want to override the singleton, use:

 public static new CustomNetworkManager singleton { get { return NetworkManager.singleton as CustomNetworkManager; } }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

155 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to transfer variables from lobby player to game player on client 0 Answers

Spawn prefabs according to player platform with LobbyManager 0 Answers

Setting the playerPrefab of network manager dynamically 1 Answer

UNet CCU is not cleared 1 Answer

i just can't seem to figure out how to make a voting system, using SyncVar hooks and commands 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges