M
M
Mirror
Search…
Network Room Manager
Please see the Room example in the Examples folder in your Mirror folder.
The Network Room Manager is a specialized type of Network Manager that provides a multiplayer room before entering the main play scene of the game. It allows you to set up a network with:
  • A maximum player limit
  • Automatic start when all players are ready
  • Game is locked after start, preventing late joiners
  • Customizable ways for players to choose options while in room
There are two types of player objects with the Network Room Manager:
Room Player Prefab
  • One for each player
  • Created when client connects, or player is added
  • Persists until client disconnects
  • Holds ready flag and configuration data
  • Handles commands in the room
  • Must use the Network Room Player component
Player Prefab
  • One for each player
  • Created when game scene is started
  • Destroyed when leaving game scene
  • Handles commands in the game

Properties

  • Show Room GUI Show the default OnGUI controls for the room.
  • Min Players Minimum number of players needed to start a game.
  • Room Player Prefab The prefab to create for players when they enter the room (requires Network Room Player component).
  • Room Scene The scene to use for the room.
  • Gameplay Scene The scene to use for main game play.
  • pendingPlayers List that holds players that are ready to start playing.
  • roomSlots List that manages the slots for connected clients in the room.
  • allPlayersReady Bool indicating if all players are ready to start playing. This value changes as players invoke CmdChangeReadyState indicating true or false, and will be set false when a new client connects.

Methods

Server Virtual Methods

1
public virtual void OnRoomStartHost() {}
2
public virtual void OnRoomStopHost() {}
3
public virtual void OnRoomStartServer() {}
4
public virtual void OnRoomServerConnect(NetworkConnection conn) {}
5
public virtual void OnRoomServerDisconnect(NetworkConnection conn) {}
6
public virtual void OnRoomServerSceneChanged(string sceneName) {}
7
public virtual GameObject OnRoomServerCreateRoomPlayer(NetworkConnection conn)
8
{
9
return null;
10
}
11
public virtual GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn)
12
{
13
return null;
14
}
15
public virtual bool OnRoomServerSceneLoadedForPlayer(GameObject roomPlayer, GameObject gamePlayer)
16
{
17
return true;
18
}
19
public virtual void OnRoomServerPlayersReady()
20
{
21
ServerChangeScene(GameplayScene);
22
}
Copied!

Client Virtual Methods

1
public virtual void OnRoomClientEnter() {}
2
public virtual void OnRoomClientExit() {}
3
public virtual void OnRoomClientConnect(NetworkConnection conn) {}
4
public virtual void OnRoomClientDisconnect(NetworkConnection conn) {}
5
public virtual void OnRoomStartClient() {}
6
public virtual void OnRoomStopClient() {}
7
public virtual void OnRoomClientSceneChanged(NetworkConnection conn) {}
8
public virtual void OnRoomClientAddPlayerFailed() {}
Copied!