Skip to content

Mirror::Examples::NetworkRoom::NetworkRoomManagerExt

Inherits from NetworkRoomManager, NetworkManager, MonoBehaviour

Public Functions

Name
virtual override bool OnRoomServerSceneLoadedForPlayer(NetworkConnection conn, GameObject roomPlayer, GameObject gamePlayer)
Called just after GamePlayer object is instantiated and just before it replaces RoomPlayer object. This is the ideal point to pass any data like player name, credentials, tokens, colors, etc. into the GamePlayer object as it is about to enter the Online scene.
virtual override void OnRoomStopClient()
This is called on the client when the client stops.
virtual override void OnRoomStopServer()
This is called on the server when the server is started - including when a host is stopped.
virtual override void OnRoomServerPlayersReady()
This is called on the server when all the players in the room are ready.
virtual override void OnGUI()
virtual so inheriting classes can roll their own

Additional inherited members

Public Classes inherited from NetworkRoomManager

Name
struct PendingPlayer

Public Functions inherited from NetworkRoomManager

Name
virtual override void OnValidate()
virtual so that inheriting classes' OnValidate() can call base.OnValidate() too
virtual override void OnServerReady(NetworkConnection conn)
Called on the server when a client is ready.
void CheckReadyToBegin()
CheckReadyToBegin checks all of the players in the room to see if their readyToBegin flag is set.
virtual override void OnServerConnect(NetworkConnection conn)
Called on the server when a new client connects.
virtual override void OnServerDisconnect(NetworkConnection conn)
Called on the server when a client disconnects.
virtual override void OnServerAddPlayer(NetworkConnection conn)
Called on the server when a client adds a new player with ClientScene.AddPlayer.
void RecalculateRoomPlayerIndices()
virtual override void ServerChangeScene(string newSceneName)
This causes the server to switch scenes and sets the networkSceneName.
virtual override void OnServerSceneChanged(string sceneName)
Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().
virtual override void OnStartServer()
This is invoked when a server is started - including when a host is started.
virtual override void OnStartHost()
This is invoked when a host is started.
virtual override void OnStopServer()
This is called when a server is stopped - including when a host is stopped.
virtual override void OnStopHost()
This is called when a host is stopped.
virtual override void OnStartClient()
This is invoked when the client is started.
virtual override void OnClientConnect(NetworkConnection conn)
Called on the client when connected to a server.
virtual override void OnClientDisconnect(NetworkConnection conn)
Called on clients when disconnected from a server.
virtual override void OnStopClient()
This is called when a client is stopped.
virtual override void OnClientSceneChanged(NetworkConnection conn)
Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
virtual void OnRoomStartHost()
This is called on the host when a host is started.
virtual void OnRoomStopHost()
This is called on the host when the host is stopped.
virtual void OnRoomStartServer()
This is called on the server when the server is started - including when a host is started.
virtual void OnRoomServerConnect(NetworkConnection conn)
This is called on the server when a new client connects to the server.
virtual void OnRoomServerDisconnect(NetworkConnection conn)
This is called on the server when a client disconnects.
virtual void OnRoomServerSceneChanged(string sceneName)
This is called on the server when a networked scene finishes loading.
virtual GameObject OnRoomServerCreateRoomPlayer(NetworkConnection conn)
This allows customization of the creation of the room-player object on the server.
virtual GameObject OnRoomServerCreateGamePlayer(NetworkConnection conn, GameObject roomPlayer)
This allows customization of the creation of the GamePlayer object on the server.
virtual void OnRoomServerAddPlayer(NetworkConnection conn)
This allows customization of the creation of the GamePlayer object on the server.
virtual void OnRoomServerPlayersNotReady()
This is called on the server when CheckReadyToBegin finds that players are not ready
virtual void OnRoomClientEnter()
This is a hook to allow custom behaviour when the game client enters the room.
virtual void OnRoomClientExit()
This is a hook to allow custom behaviour when the game client exits the room.
virtual void OnRoomClientConnect(NetworkConnection conn)
This is called on the client when it connects to server.
virtual void OnRoomClientDisconnect(NetworkConnection conn)
This is called on the client when disconnected from a server.
virtual void OnRoomStartClient()
This is called on the client when a client is started.
virtual void OnRoomClientSceneChanged(NetworkConnection conn)
This is called on the client when the client is finished loading a new networked scene.
virtual void OnRoomClientAddPlayerFailed()
Called on the client when adding a player to the room fails.

Public Properties inherited from NetworkRoomManager

Name
bool allPlayersReady

Public Attributes inherited from NetworkRoomManager

Name
string RoomScene
The scene to use for the room. This is similar to the offlineScene of the NetworkManager.
string GameplayScene
The scene to use for the playing the game from the room. This is similar to the onlineScene of the NetworkManager.
List< PendingPlayer > pendingPlayers
List of players that are in the Room
List< NetworkRoomPlayer > roomSlots
These slots track players that enter the room.
int clientIndex

Protected Attributes inherited from NetworkRoomManager

Name
int minPlayers
NetworkRoomPlayer roomPlayerPrefab

Public Functions inherited from NetworkManager

Name
virtual void OnValidate()
virtual so that inheriting classes' OnValidate() can call base.OnValidate() too
virtual void Awake()
virtual so that inheriting classes' Awake() can call base.Awake() too
virtual void Start()
virtual so that inheriting classes' Start() can call base.Start() too
virtual void LateUpdate()
virtual so that inheriting classes' LateUpdate() can call base.LateUpdate() too
void StartServer()
This starts a new server.
void StartClient()
This starts a network client. It uses the networkAddress property as the address to connect to.
void StartClient(Uri uri)
This starts a network client. It uses the Uri parameter as the address to connect to.
void StartHost()
This starts a network "host" - a server and client in the same application.
void StopHost()
This stops both the client and the server that the manager is using.
void StopServer()
Stops the server that the manager is using.
void StopClient()
Stops the client that the manager is using.
virtual void OnApplicationQuit()
called when quitting the application by closing the window / pressing stop in the editor
virtual void ConfigureServerFrameRate()
Set the frame rate for a headless server.
virtual void OnDestroy()
virtual so that inheriting classes' OnDestroy() can call base.OnDestroy() too
virtual void ServerChangeScene(string newSceneName)
This causes the server to switch scenes and sets the networkSceneName.
Transform GetStartPosition()
This finds a spawn position based on NetworkStartPosition objects in the scene.
virtual void OnServerConnect(NetworkConnection conn)
Called on the server when a new client connects.
virtual void OnServerDisconnect(NetworkConnection conn)
Called on the server when a client disconnects.
virtual void OnServerReady(NetworkConnection conn)
Called on the server when a client is ready.
virtual void OnServerAddPlayer(NetworkConnection conn)
Called on the server when a client adds a new player with ClientScene.AddPlayer.
virtual void OnServerError(NetworkConnection conn, int errorCode)
Called on the server when a network error occurs for a client connection.
virtual void OnServerChangeScene(string newSceneName)
Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed
virtual void OnServerSceneChanged(string sceneName)
Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().
virtual void OnClientConnect(NetworkConnection conn)
Called on the client when connected to a server.
virtual void OnClientDisconnect(NetworkConnection conn)
Called on clients when disconnected from a server.
virtual void OnClientError(NetworkConnection conn, int errorCode)
Called on clients when a network error occurs.
virtual void OnClientNotReady(NetworkConnection conn)
Called on clients when a servers tells the client it is no longer ready.
virtual void OnClientChangeScene(string newSceneName, SceneOperation sceneOperation, bool customHandling)
Called from ClientChangeScene immediately before SceneManager.LoadSceneAsync is executed
virtual void OnClientSceneChanged(NetworkConnection conn)
Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
virtual void OnStartHost()
This is invoked when a host is started.
virtual void OnStartServer()
This is invoked when a server is started - including when a host is started.
virtual void OnStartClient()
This is invoked when the client is started.
virtual void OnStopServer()
This is called when a server is stopped - including when a host is stopped.
virtual void OnStopClient()
This is called when a client is stopped.
virtual void OnStopHost()
This is called when a host is stopped.
bool IsSceneActive(string scene)
void Shutdown()
This is the only way to clear the singleton, so another instance can be created.
void RegisterStartPosition(Transform start)
Registers the transform of a game object as a player spawn location.
void UnRegisterStartPosition(Transform start)
Unregisters the transform of a game object as a player spawn location.

Public Properties inherited from NetworkManager

Name
NetworkManager singleton
NetworkManager singleton
NetworkManagerMode mode
string networkSceneName
The name of the current network scene.

Public Attributes inherited from NetworkManager

Name
bool dontDestroyOnLoad
A flag to control whether the NetworkManager object is destroyed when the scene changes.
bool runInBackground
Controls whether the program runs when it is in the background.
bool autoStartServerBuild
Automatically invoke StartServer()
bool showDebugMessages
Enables verbose debug messages in the console
int serverTickRate
Server Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.
string offlineScene
The scene to switch to when offline.
string onlineScene
The scene to switch to when online.
string networkAddress
The network address currently in use.
int maxConnections
The maximum number of concurrent network connections to support.
bool disconnectInactiveConnections
Should the server disconnect remote connections that have gone silent for more than Server Idle Timeout?
float disconnectInactiveTimeout
Timeout in seconds since last message from a client after which server will auto-disconnect.
NetworkAuthenticator authenticator
GameObject playerPrefab
The default prefab to be used to create player objects on the server.
bool autoCreatePlayer
A flag to control whether or not player objects are automatically created on connect, and on scene change.
PlayerSpawnMethod playerSpawnMethod
The current method of spawning players used by the NetworkManager.
List< GameObject > spawnPrefabs
List of prefabs that will be registered with the spawning system.
int numPlayers
Number of active player objects across all connections on the server.
bool isNetworkActive
True if the server or client is started and running
bool clientLoadedScene
This is true if the client loaded a new scene when connecting to the server.
UnityEngine.AsyncOperation loadingSceneAsync
int startPositionIndex
List< Transform > startPositions
List of transforms populted by NetworkStartPosition components found in the scene.

Protected Attributes inherited from NetworkManager

Name
Transport transport

Public Functions Documentation

function OnRoomServerSceneLoadedForPlayer

inline virtual override bool OnRoomServerSceneLoadedForPlayer(
    NetworkConnection conn,
    GameObject roomPlayer,
    GameObject gamePlayer
)

Called just after GamePlayer object is instantiated and just before it replaces RoomPlayer object. This is the ideal point to pass any data like player name, credentials, tokens, colors, etc. into the GamePlayer object as it is about to enter the Online scene.

Parameters:

  • roomPlayer
  • gamePlayer

Return: true unless some code in here decides it needs to abort the replacement

Reimplements: Mirror::NetworkRoomManager::OnRoomServerSceneLoadedForPlayer

function OnRoomStopClient

inline virtual override void OnRoomStopClient()

This is called on the client when the client stops.

Reimplements: Mirror::NetworkRoomManager::OnRoomStopClient

function OnRoomStopServer

inline virtual override void OnRoomStopServer()

This is called on the server when the server is started - including when a host is stopped.

Reimplements: Mirror::NetworkRoomManager::OnRoomStopServer

function OnRoomServerPlayersReady

inline virtual override void OnRoomServerPlayersReady()

This is called on the server when all the players in the room are ready.

Reimplements: Mirror::NetworkRoomManager::OnRoomServerPlayersReady

The default implementation of this function uses ServerChangeScene() to switch to the game player scene. By implementing this callback you can customize what happens when all the players in the room are ready, such as adding a countdown or a confirmation for a group leader.

function OnGUI

inline virtual override void OnGUI()

virtual so inheriting classes can roll their own

Reimplements: Mirror::NetworkRoomManager::OnGUI


Updated on 21 January 2021 at 11:06:37 UTC