Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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.

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

[Multiplayer Lobby] NetworkManager has a NetworkIdentity component 1 Answer

Modifying Unity Network Lobby 0 Answers

Exiting a UNET lobby causes future ClientRPC calls to be ignored. 1 Answer

Match options in unet for servers list. 0 Answers

How can players select their own preferences in the lobby? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges