Mirror Networking
|
Public Member Functions | |
virtual void | OnValidate () |
virtual void | Reset () |
virtual void | Awake () |
virtual void | Start () |
virtual void | LateUpdate () |
void | StartServer () |
Starts the server, listening for incoming connections. More... | |
void | StartClient () |
Starts the client, connects it to the server with networkAddress. More... | |
void | StartClient (Uri uri) |
Starts the client, connects it to the server via Uri More... | |
void | StartHost () |
Starts a network "host" - a server and client in the same application. More... | |
void | StopHost () |
This stops both the client and the server that the manager is using. More... | |
void | StopServer () |
Stops the server from listening and simulating the game. More... | |
void | StopClient () |
Stops and disconnects the client. More... | |
virtual void | OnApplicationQuit () |
virtual void | ConfigureHeadlessFrameRate () |
Set the frame rate for a headless builds. Override to disable or modify. More... | |
virtual void | OnDestroy () |
virtual void | ServerChangeScene (string newSceneName) |
Change the server scene and all client's scenes across the network. More... | |
Transform | GetStartPosition () |
Get the next NetworkStartPosition based on the selected PlayerSpawnMethod. More... | |
virtual void | OnServerConnect (NetworkConnectionToClient conn) |
Called on the server when a new client connects. More... | |
virtual void | OnServerDisconnect (NetworkConnectionToClient conn) |
Called on the server when a client disconnects. More... | |
virtual void | OnServerReady (NetworkConnectionToClient conn) |
Called on the server when a client is ready (= loaded the scene) More... | |
virtual void | OnServerAddPlayer (NetworkConnectionToClient conn) |
Called on server when a client requests to add the player. Adds playerPrefab by default. Can be overwritten. More... | |
virtual void | OnServerError (NetworkConnectionToClient conn, Exception exception) |
virtual void | OnServerError (NetworkConnectionToClient conn, TransportError error, string reason) |
Called on server when transport raises an exception. NetworkConnection may be null. More... | |
virtual void | OnServerChangeScene (string newSceneName) |
Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed More... | |
virtual void | OnServerSceneChanged (string sceneName) |
Called on server after a scene load with ServerChangeScene() is completed. More... | |
virtual void | OnClientConnect () |
Called on the client when connected to a server. By default it sets client as ready and adds a player. More... | |
virtual void | OnClientDisconnect () |
Called on clients when disconnected from a server. More... | |
virtual void | OnClientError (Exception exception) |
virtual void | OnClientError (TransportError error, string reason) |
Called on client when transport raises an exception. More... | |
virtual void | OnClientNotReady () |
Called on clients when a servers tells the client it is no longer ready, e.g. when switching scenes. More... | |
virtual void | OnClientChangeScene (string newSceneName, SceneOperation sceneOperation, bool customHandling) |
Called from ClientChangeScene immediately before SceneManager.LoadSceneAsync is executed More... | |
virtual void | OnClientSceneChanged () |
Called on clients when a scene has completed loaded, when the scene load was initiated by the server. More... | |
virtual void | OnStartHost () |
This is invoked when a host is started. More... | |
virtual void | OnStartServer () |
This is invoked when a server is started - including when a host is started. More... | |
virtual void | OnStartClient () |
This is invoked when the client is started. More... | |
virtual void | OnStopServer () |
This is called when a server is stopped - including when a host is stopped. More... | |
virtual void | OnStopClient () |
This is called when a client is stopped. More... | |
virtual void | OnStopHost () |
This is called when a host is stopped. More... | |
Static Public Member Functions | |
static bool | IsSceneActive (string scene) |
static void | ResetStatics () |
static void | RegisterStartPosition (Transform start) |
Registers the transform of a game object as a player spawn location. More... | |
static void | UnRegisterStartPosition (Transform start) |
Unregister a Transform from start positions. More... | |
Public Attributes | |
bool | dontDestroyOnLoad = true |
Enable to keep NetworkManager alive when changing scenes. More... | |
bool | runInBackground = true |
Multiplayer games should always run in the background so the network doesn't time out. More... | |
bool | autoStartServerBuild = true |
Should the server auto-start when 'Server Build' is checked in build settings More... | |
int | serverTickRate = 30 |
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. More... | |
string | offlineScene = "" |
Automatically switch to this scene upon going offline (on start / on disconnect / on shutdown). More... | |
string | onlineScene = "" |
Automatically switch to this scene upon going online (after connect/startserver). More... | |
string | networkAddress = "localhost" |
Server's address for clients to connect to. More... | |
int | maxConnections = 100 |
The maximum number of concurrent network connections to support. More... | |
NetworkAuthenticator | authenticator |
GameObject | playerPrefab |
The default prefab to be used to create player objects on the server. More... | |
bool | autoCreatePlayer = true |
Enable to automatically create player objects on connect and on scene change. More... | |
PlayerSpawnMethod | playerSpawnMethod |
Where to spawn players. More... | |
List< GameObject > | spawnPrefabs = new List<GameObject>() |
Prefabs that can be spawned over the network need to be registered here. More... | |
Static Public Attributes | |
static List< Transform > | startPositions = new List<Transform>() |
List of transforms populated by NetworkStartPositions More... | |
static int | startPositionIndex |
static AsyncOperation | loadingSceneAsync |
Protected Member Functions | |
void | FinishLoadScene () |
Protected Attributes | |
Transport | transport |
bool | clientLoadedScene |
True if the client loaded a new scene when connecting to the server. More... | |
Properties | |
static NetworkManager | singleton [get, set] |
The one and only NetworkManager More... | |
int | numPlayers [get] |
Number of active player objects across all connections on the server. More... | |
bool | isNetworkActive [get] |
True if the server is running or client is connected/connecting. More... | |
NetworkManagerMode | mode [get] |
static string | networkSceneName = "" [get, protected set] |
The name of the current network scene. More... | |
Definition at line 17 of file NetworkManager.cs.
|
virtual |
Definition at line 185 of file NetworkManager.cs.
|
virtual |
Set the frame rate for a headless builds. Override to disable or modify.
Definition at line 642 of file NetworkManager.cs.
|
protected |
Definition at line 919 of file NetworkManager.cs.
Transform Mirror.NetworkManager.GetStartPosition | ( | ) |
Get the next NetworkStartPosition based on the selected PlayerSpawnMethod.
Definition at line 1056 of file NetworkManager.cs.
|
static |
Definition at line 229 of file NetworkManager.cs.
|
virtual |
Definition at line 217 of file NetworkManager.cs.
|
virtual |
Definition at line 617 of file NetworkManager.cs.
|
virtual |
Called from ClientChangeScene immediately before SceneManager.LoadSceneAsync is executed
Definition at line 1306 of file NetworkManager.cs.
|
virtual |
Called on the client when connected to a server. By default it sets client as ready and adds a player.
Definition at line 1264 of file NetworkManager.cs.
|
virtual |
Called on clients when disconnected from a server.
Definition at line 1282 of file NetworkManager.cs.
|
virtual |
Definition at line 1292 of file NetworkManager.cs.
|
virtual |
Called on client when transport raises an exception.
Definition at line 1294 of file NetworkManager.cs.
|
virtual |
Called on clients when a servers tells the client it is no longer ready, e.g. when switching scenes.
Definition at line 1302 of file NetworkManager.cs.
|
virtual |
Called on clients when a scene has completed loaded, when the scene load was initiated by the server.
Definition at line 1312 of file NetworkManager.cs.
|
virtual |
Definition at line 734 of file NetworkManager.cs.
|
virtual |
Called on server when a client requests to add the player. Adds playerPrefab by default. Can be overwritten.
Definition at line 1233 of file NetworkManager.cs.
|
virtual |
Called from ServerChangeScene immediately before SceneManager.LoadSceneAsync is executed
Definition at line 1258 of file NetworkManager.cs.
|
virtual |
Called on the server when a new client connects.
Definition at line 1207 of file NetworkManager.cs.
|
virtual |
Called on the server when a client disconnects.
Definition at line 1211 of file NetworkManager.cs.
|
virtual |
Definition at line 1248 of file NetworkManager.cs.
|
virtual |
Called on server when transport raises an exception. NetworkConnection may be null.
Definition at line 1250 of file NetworkManager.cs.
|
virtual |
Called on the server when a client is ready (= loaded the scene)
Definition at line 1221 of file NetworkManager.cs.
|
virtual |
Called on server after a scene load with ServerChangeScene() is completed.
Definition at line 1261 of file NetworkManager.cs.
|
virtual |
This is invoked when the client is started.
Definition at line 1337 of file NetworkManager.cs.
|
virtual |
|
virtual |
This is invoked when a server is started - including when a host is started.
Definition at line 1334 of file NetworkManager.cs.
|
virtual |
|
virtual |
|
virtual |
This is called when a server is stopped - including when a host is stopped.
Definition at line 1340 of file NetworkManager.cs.
|
virtual |
Definition at line 126 of file NetworkManager.cs.
|
static |
Registers the transform of a game object as a player spawn location.
This is done automatically by NetworkStartPosition components, but can be done manually from user script code.
start | Transform to register. |
Definition at line 1034 of file NetworkManager.cs.
|
virtual |
Definition at line 149 of file NetworkManager.cs.
|
static |
Definition at line 716 of file NetworkManager.cs.
|
virtual |
Change the server scene and all client's scenes across the network.
Definition at line 752 of file NetworkManager.cs.
|
virtual |
Definition at line 201 of file NetworkManager.cs.
void Mirror.NetworkManager.StartClient | ( | ) |
Starts the client, connects it to the server with networkAddress.
Definition at line 311 of file NetworkManager.cs.
void Mirror.NetworkManager.StartClient | ( | Uri | uri | ) |
Starts the client, connects it to the server via Uri
Definition at line 350 of file NetworkManager.cs.
void Mirror.NetworkManager.StartHost | ( | ) |
Starts a network "host" - a server and client in the same application.
Definition at line 382 of file NetworkManager.cs.
void Mirror.NetworkManager.StartServer | ( | ) |
Starts the server, listening for incoming connections.
Definition at line 270 of file NetworkManager.cs.
void Mirror.NetworkManager.StopClient | ( | ) |
Stops and disconnects the client.
Definition at line 568 of file NetworkManager.cs.
void Mirror.NetworkManager.StopHost | ( | ) |
This stops both the client and the server that the manager is using.
Definition at line 510 of file NetworkManager.cs.
void Mirror.NetworkManager.StopServer | ( | ) |
Stops the server from listening and simulating the game.
Definition at line 526 of file NetworkManager.cs.
|
static |
Unregister a Transform from start positions.
Definition at line 1049 of file NetworkManager.cs.
NetworkAuthenticator Mirror.NetworkManager.authenticator |
Definition at line 71 of file NetworkManager.cs.
bool Mirror.NetworkManager.autoCreatePlayer = true |
Enable to automatically create player objects on connect and on scene change.
Definition at line 84 of file NetworkManager.cs.
bool Mirror.NetworkManager.autoStartServerBuild = true |
Should the server auto-start when 'Server Build' is checked in build settings
Definition at line 34 of file NetworkManager.cs.
|
protected |
True if the client loaded a new scene when connecting to the server.
Definition at line 115 of file NetworkManager.cs.
bool Mirror.NetworkManager.dontDestroyOnLoad = true |
Enable to keep NetworkManager alive when changing scenes.
Definition at line 24 of file NetworkManager.cs.
|
static |
Definition at line 745 of file NetworkManager.cs.
int Mirror.NetworkManager.maxConnections = 100 |
The maximum number of concurrent network connections to support.
Definition at line 67 of file NetworkManager.cs.
string Mirror.NetworkManager.networkAddress = "localhost" |
Server's address for clients to connect to.
Definition at line 62 of file NetworkManager.cs.
string Mirror.NetworkManager.offlineScene = "" |
Automatically switch to this scene upon going offline (on start / on disconnect / on shutdown).
Definition at line 45 of file NetworkManager.cs.
string Mirror.NetworkManager.onlineScene = "" |
Automatically switch to this scene upon going online (after connect/startserver).
Definition at line 51 of file NetworkManager.cs.
GameObject Mirror.NetworkManager.playerPrefab |
The default prefab to be used to create player objects on the server.
Definition at line 79 of file NetworkManager.cs.
PlayerSpawnMethod Mirror.NetworkManager.playerSpawnMethod |
Where to spawn players.
Definition at line 89 of file NetworkManager.cs.
bool Mirror.NetworkManager.runInBackground = true |
Multiplayer games should always run in the background so the network doesn't time out.
Definition at line 29 of file NetworkManager.cs.
int Mirror.NetworkManager.serverTickRate = 30 |
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.
Definition at line 38 of file NetworkManager.cs.
List<GameObject> Mirror.NetworkManager.spawnPrefabs = new List<GameObject>() |
Prefabs that can be spawned over the network need to be registered here.
Definition at line 93 of file NetworkManager.cs.
|
static |
Definition at line 97 of file NetworkManager.cs.
|
static |
List of transforms populated by NetworkStartPositions
Definition at line 96 of file NetworkManager.cs.
|
protected |
Definition at line 57 of file NetworkManager.cs.
|
get |
True if the server is running or client is connected/connecting.
Definition at line 106 of file NetworkManager.cs.
|
get |
Definition at line 123 of file NetworkManager.cs.
|
staticgetprotected set |
The name of the current network scene.
Definition at line 743 of file NetworkManager.cs.
|
get |
Number of active player objects across all connections on the server.
Definition at line 103 of file NetworkManager.cs.
|
staticgetset |
The one and only NetworkManager
Definition at line 100 of file NetworkManager.cs.