Comment on page
Creating and Joining a Lobby
First of all, create a scene named 0_scene.
- The prefix 0_ helps us organize our scenes better.
- Add it to Building Setting.
Next, rename our scene folder to _Scenes.
The "_" prefix ensures that our scenes always appear at the top of our Assets Hierarchy. This is necessary because some packages may use default names and potentially override our folder.
The new scene will look like below:
Here is everything we need to create in order to make Lobby work.
- Title (text): is unchangeable and always contains the LobbyID text.
- ID (text): receives the lobby ID after a player creates or joins a lobby.
- InputMaxPlayer: defines the maximum number of players who can join the lobby.
- Create Lobby button: sends a lobby creation request to Unity Lobby.
- InputLobbyCode: displays the lobby code for the lobby owner or allows players to enter an existing lobby code.
- Join Lobby button: allows joining an existing Lobby, is disabled if players already have a lobby.
- InputPlayerCount: is read-only, can use Text Mesh Pro for displaying the player count.
- Start Game button: allows lobby creators to start the game.
All the Inputs and Buttons in the UI will will be controlled by a Lobby Manager Script, which facilitates the display and interaction within the lobby.
While there is not a specific document for the Lobby Manager Script, we'll gain an understanding of how it works as we explore the documentation for each element within the Lobby UI.
Here's a preview of what the Lobby Manager Inspector looks like. Take a moment to review it before we proceed.
You don't have to adhere strictly to my approach, as it may not necessarily be the best practice. However, this is how I personally organize my scripts for the lobby.