Mirror::Examples::Basic::BasicNetManager
Inherits from NetworkManager, MonoBehaviour
Public Functions
Name | |
---|---|
virtual override void | OnServerAddPlayer(NetworkConnection conn) Called on the server when a client adds a new player with ClientScene.AddPlayer. |
Additional inherited members
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 | 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 OnServerAddPlayer
inline virtual override void OnServerAddPlayer(
NetworkConnection conn
)
Called on the server when a client adds a new player with ClientScene.AddPlayer.
Parameters:
- conn Connection from client.
Reimplements: Mirror::NetworkManager::OnServerAddPlayer
The default implementation for this function creates a new player object from the playerPrefab.
Updated on 25 January 2021 at 08:57:30 UTC