Many multiplayer games have a staging area for players to join before playing the actual game. In this area - often called the “lobby”, players may be able to pick options and be able to set themselves as ready for the game to start.
The NetworkLobbyManager is a specialized NetworkManager that provides a lobby for Unity Multiplayer games. It includes:
The GuiLobbyManager is a special lobby manager that provides a user-interface for the lobby. It is available as an asset package and can be imported into Unity projects to easily add a lobby to multiplayer games. The scripts and UI prefabs in the package can be customized to make the look and feel of the lobby unique for any game.
There are two kinds of player objects - each which has a prefab slot in the NetworkLobbyManager:
LobbyPlayer Object
GamePlayer Object
The NetworkLobbyPlayer component is used for LobbyPlayer objects. It supplies some virtual function callbacks that can be used for custom lobby behaviour
public virtual void OnClientEnterLobby()
{
}
public virtual void OnClientExitLobby()
{
}
public virtual void OnClientReady(bool readyState)
{
}
Process for adding a NetworkLobby to a multiplayer game (without using the multiplayer-lobby asset package):
This version of the NetworkLobbyManager uses the OnGUI user interface like the NetworkManagerHUD. For a better user interface use the multiplayer-lobby asset package.
The NetworkLobbyManager has many virtual function callbacks that can be used for custom lobby behaviour. Most important is OnLobbyServerSceneLoadedForPlayer which is called on the server for each player as they transition from the lobby to the main game. This is the ideal place to apply settings from the lobby to the player’s game-play object.
// for users to apply settings from their lobby player object to their in-game player object
public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)
{
var cc = lobbyPlayer.GetComponent<ColorControl>();
var player = gamePlayer.GetComponent<Player>();
player.myColor = cc.myColor;
return true;
}
When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
More information
These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.
These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.
These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.