C# Class UnityEngine.Networking.NetworkManager

Inheritance: UnityEngine.MonoBehaviour
ファイルを表示 Open project: CarlosHBC/UnityDecompiled Class Usage Examples

Public Properties

Property Type Description
client NetworkClient
isNetworkActive bool
matchInfo MatchInfo
matchMaker NetworkMatch
matches List
networkSceneName string
singleton NetworkManager

Private Properties

Property Type Description
Awake void
CleanupNetworkIdentities void
ClientChangeScene void
ConnectLocalClient NetworkClient
FinishLoadScene void
InitializeSingleton void
OnClientConnectInternal void
OnClientDisconnectInternal void
OnClientErrorInternal void
OnClientNotReadyMessageInternal void
OnClientSceneInternal void
OnDestroy void
OnDomainReload void
OnServerAddPlayerInternal void
OnServerAddPlayerMessageInternal void
OnServerConnectInternal void
OnServerDisconnectInternal void
OnServerErrorInternal void
OnServerReadyMessageInternal void
OnServerRemovePlayerMessageInternal void
OnValidate void
RegisterClientMessages void
RegisterServerMessages void
StartServer bool
UpdateScene void

Public Methods

Method Description
GetStartPosition ( ) : Transform

This finds a spawn position based on NetworkStartPosition objects in the scene.

IsClientConnected ( ) : bool

This checks if the NetworkManager has a client and that it is connected to a server.

NetworkManager ( ) : System
OnClientConnect ( NetworkConnection conn ) : void

Called on the client when connected to a server.

OnClientDisconnect ( NetworkConnection conn ) : void

Called on clients when disconnected from a server.

OnClientError ( NetworkConnection conn, int errorCode ) : void

Called on clients when a network error occurs.

OnClientNotReady ( NetworkConnection conn ) : void

Called on clients when a servers tells the client it is no longer ready.

OnClientSceneChanged ( NetworkConnection conn ) : void

Called on clients when a scene has completed loaded, when the scene load was initiated by the server.

OnDestroyMatch ( bool success, string extendedInfo ) : void

Callback that happens when a NetworkMatch.DestroyMatch request has been processed on the server.

OnDropConnection ( bool success, string extendedInfo ) : void

Callback that happens when a NetworkMatch.DropConnection match request has been processed on the server.

OnMatchCreate ( bool success, string extendedInfo, MatchInfo matchInfo ) : void

Callback that happens when a NetworkMatch.CreateMatch request has been processed on the server.

OnMatchJoined ( bool success, string extendedInfo, MatchInfo matchInfo ) : void

Callback that happens when a NetworkMatch.JoinMatch request has been processed on the server.

OnMatchList ( bool success, string extendedInfo, List matchList ) : void
OnServerAddPlayer ( NetworkConnection conn, short playerControllerId ) : void

Called on the server when a client adds a new player with ClientScene.AddPlayer.

OnServerAddPlayer ( NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader ) : void
OnServerConnect ( NetworkConnection conn ) : void

Called on the server when a new client connects.

OnServerDisconnect ( NetworkConnection conn ) : void

Called on the server when a client disconnects.

OnServerError ( NetworkConnection conn, int errorCode ) : void

Called on the server when a network error occurs for a client connection.

OnServerReady ( NetworkConnection conn ) : void

Called on the server when a client is ready.

OnServerRemovePlayer ( NetworkConnection conn, PlayerController player ) : void

Called on the server when a client removes a player.

OnServerSceneChanged ( string sceneName ) : void

Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().

OnSetMatchAttributes ( bool success, string extendedInfo ) : void

Callback that happens when a NetworkMatch.SetMatchAttributes has been processed on the server.

OnStartClient ( NetworkClient client ) : void

This is a hook that is invoked when the client is started.

OnStartHost ( ) : void

This hook is invoked when a host is started.

OnStartServer ( ) : void

This hook is invoked when a server is started - including when a host is started.

OnStopClient ( ) : void

This hook is called when a client is stopped.

OnStopHost ( ) : void

This hook is called when a host is stopped.

OnStopServer ( ) : void

This hook is called when a server is stopped - including when a host is stopped.

RegisterStartPosition ( Transform start ) : void

Registers the transform of a game object as a player spawn location.

ServerChangeScene ( string newSceneName ) : void

This causes the server to switch scenes and sets the networkSceneName.

SetMatchHost ( string newHost, int port, bool https ) : void

This sets the address of the MatchMaker service.

SetupMigrationManager ( NetworkMigrationManager man ) : void

This sets up a NetworkMigrationManager object to work with this NetworkManager.

Shutdown ( ) : void

Shuts down the NetworkManager completely and destroy the singleton.

StartClient ( ) : NetworkClient

This starts a network client. It uses the networkAddress and networkPort properties as the address to connect to.

StartClient ( MatchInfo matchInfo ) : NetworkClient
StartClient ( MatchInfo info, ConnectionConfig config ) : NetworkClient
StartHost ( ) : NetworkClient

This starts a network "host" - a server and client in the same application.

StartHost ( ConnectionConfig config, int maxConnections ) : NetworkClient
StartHost ( MatchInfo info ) : NetworkClient
StartMatchMaker ( ) : void

This starts MatchMaker for the NetworkManager.

StartServer ( ) : bool

This starts a new server.

StartServer ( ConnectionConfig config, int maxConnections ) : bool
StartServer ( MatchInfo info ) : bool
StopClient ( ) : void

Stops the client that the manager is using.

StopHost ( ) : void

This stops both the client and the server that the manager is using.

StopMatchMaker ( ) : void

Stops the MatchMaker that the NetworkManager is using.

StopServer ( ) : void

Stops the server that the manager is using.

UnRegisterStartPosition ( Transform start ) : void

Unregisters the transform of a game object as a player spawn location.

UseExternalClient ( NetworkClient externalClient ) : void

This allows the NetworkManager to use a client object created externally to the NetworkManager instead of using StartClient().

Private Methods

Method Description
Awake ( ) : void
CleanupNetworkIdentities ( ) : void
ClientChangeScene ( string newSceneName, bool forceReload ) : void
ConnectLocalClient ( ) : NetworkClient
FinishLoadScene ( ) : void
InitializeSingleton ( ) : void
OnClientConnectInternal ( NetworkMessage netMsg ) : void
OnClientDisconnectInternal ( NetworkMessage netMsg ) : void
OnClientErrorInternal ( NetworkMessage netMsg ) : void
OnClientNotReadyMessageInternal ( NetworkMessage netMsg ) : void
OnClientSceneInternal ( NetworkMessage netMsg ) : void
OnDestroy ( ) : void
OnDomainReload ( ) : void
OnServerAddPlayerInternal ( NetworkConnection conn, short playerControllerId ) : void
OnServerAddPlayerMessageInternal ( NetworkMessage netMsg ) : void
OnServerConnectInternal ( NetworkMessage netMsg ) : void
OnServerDisconnectInternal ( NetworkMessage netMsg ) : void
OnServerErrorInternal ( NetworkMessage netMsg ) : void
OnServerReadyMessageInternal ( NetworkMessage netMsg ) : void
OnServerRemovePlayerMessageInternal ( NetworkMessage netMsg ) : void
OnValidate ( ) : void
RegisterClientMessages ( NetworkClient client ) : void
RegisterServerMessages ( ) : void
StartServer ( MatchInfo info, ConnectionConfig config, int maxConnections ) : bool
UpdateScene ( ) : void

Method Details

GetStartPosition() public method

This finds a spawn position based on NetworkStartPosition objects in the scene.

public GetStartPosition ( ) : Transform
return UnityEngine.Transform

IsClientConnected() public method

This checks if the NetworkManager has a client and that it is connected to a server.

public IsClientConnected ( ) : bool
return bool

NetworkManager() public method

public NetworkManager ( ) : System
return System

OnClientConnect() public method

Called on the client when connected to a server.

public OnClientConnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection to the server.
return void

OnClientDisconnect() public method

Called on clients when disconnected from a server.

public OnClientDisconnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection to the server.
return void

OnClientError() public method

Called on clients when a network error occurs.

public OnClientError ( NetworkConnection conn, int errorCode ) : void
conn NetworkConnection Connection to a server.
errorCode int Error code.
return void

OnClientNotReady() public method

Called on clients when a servers tells the client it is no longer ready.

public OnClientNotReady ( NetworkConnection conn ) : void
conn NetworkConnection Connection to a server.
return void

OnClientSceneChanged() public method

Called on clients when a scene has completed loaded, when the scene load was initiated by the server.

public OnClientSceneChanged ( NetworkConnection conn ) : void
conn NetworkConnection The network connection that the scene change message arrived on.
return void

OnDestroyMatch() public method

Callback that happens when a NetworkMatch.DestroyMatch request has been processed on the server.

public OnDestroyMatch ( bool success, string extendedInfo ) : void
success bool Indicates if the request succeeded.
extendedInfo string A text description for the error if success is false.
return void

OnDropConnection() public method

Callback that happens when a NetworkMatch.DropConnection match request has been processed on the server.

public OnDropConnection ( bool success, string extendedInfo ) : void
success bool Indicates if the request succeeded.
extendedInfo string A text description for the error if success is false.
return void

OnMatchCreate() public method

Callback that happens when a NetworkMatch.CreateMatch request has been processed on the server.

public OnMatchCreate ( bool success, string extendedInfo, MatchInfo matchInfo ) : void
success bool Indicates if the request succeeded.
extendedInfo string A text description for the error if success is false.
matchInfo UnityEngine.Networking.Match.MatchInfo The information about the newly created match.
return void

OnMatchJoined() public method

Callback that happens when a NetworkMatch.JoinMatch request has been processed on the server.

public OnMatchJoined ( bool success, string extendedInfo, MatchInfo matchInfo ) : void
success bool Indicates if the request succeeded.
extendedInfo string A text description for the error if success is false.
matchInfo UnityEngine.Networking.Match.MatchInfo The info for the newly joined match.
return void

OnMatchList() public method

public OnMatchList ( bool success, string extendedInfo, List matchList ) : void
success bool
extendedInfo string
matchList List
return void

OnServerAddPlayer() public method

Called on the server when a client adds a new player with ClientScene.AddPlayer.

public OnServerAddPlayer ( NetworkConnection conn, short playerControllerId ) : void
conn NetworkConnection Connection from client.
playerControllerId short Id of the new player.
return void

OnServerAddPlayer() public method

public OnServerAddPlayer ( NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader ) : void
conn NetworkConnection
playerControllerId short
extraMessageReader NetworkReader
return void

OnServerConnect() public method

Called on the server when a new client connects.

public OnServerConnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection from client.
return void

OnServerDisconnect() public method

Called on the server when a client disconnects.

public OnServerDisconnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection from client.
return void

OnServerError() public method

Called on the server when a network error occurs for a client connection.

public OnServerError ( NetworkConnection conn, int errorCode ) : void
conn NetworkConnection Connection from client.
errorCode int Error code.
return void

OnServerReady() public method

Called on the server when a client is ready.

public OnServerReady ( NetworkConnection conn ) : void
conn NetworkConnection Connection from client.
return void

OnServerRemovePlayer() public method

Called on the server when a client removes a player.

public OnServerRemovePlayer ( NetworkConnection conn, PlayerController player ) : void
conn NetworkConnection The connection to remove the player from.
player PlayerController The player controller to remove.
return void

OnServerSceneChanged() public method

Called on the server when a scene is completed loaded, when the scene load was initiated by the server with ServerChangeScene().

public OnServerSceneChanged ( string sceneName ) : void
sceneName string The name of the new scene.
return void

OnSetMatchAttributes() public method

Callback that happens when a NetworkMatch.SetMatchAttributes has been processed on the server.

public OnSetMatchAttributes ( bool success, string extendedInfo ) : void
success bool Indicates if the request succeeded.
extendedInfo string A text description for the error if success is false.
return void

OnStartClient() public method

This is a hook that is invoked when the client is started.

public OnStartClient ( NetworkClient client ) : void
client NetworkClient The NetworkClient object that was started.
return void

OnStartHost() public method

This hook is invoked when a host is started.

public OnStartHost ( ) : void
return void

OnStartServer() public method

This hook is invoked when a server is started - including when a host is started.

public OnStartServer ( ) : void
return void

OnStopClient() public method

This hook is called when a client is stopped.

public OnStopClient ( ) : void
return void

OnStopHost() public method

This hook is called when a host is stopped.

public OnStopHost ( ) : void
return void

OnStopServer() public method

This hook is called when a server is stopped - including when a host is stopped.

public OnStopServer ( ) : void
return void

RegisterStartPosition() public static method

Registers the transform of a game object as a player spawn location.

public static RegisterStartPosition ( Transform start ) : void
start UnityEngine.Transform Transform to register.
return void

ServerChangeScene() public method

This causes the server to switch scenes and sets the networkSceneName.

public ServerChangeScene ( string newSceneName ) : void
newSceneName string The name of the scene to change to. The server will change scene immediately, and a message will be sent to connected clients to ask them to change scene also.
return void

SetMatchHost() public method

This sets the address of the MatchMaker service.

public SetMatchHost ( string newHost, int port, bool https ) : void
newHost string Hostname of MatchMaker service.
port int Port of MatchMaker service.
https bool Protocol used by MatchMaker service.
return void

SetupMigrationManager() public method

This sets up a NetworkMigrationManager object to work with this NetworkManager.

public SetupMigrationManager ( NetworkMigrationManager man ) : void
man NetworkMigrationManager The migration manager object to use with the NetworkManager.
return void

Shutdown() public static method

Shuts down the NetworkManager completely and destroy the singleton.

public static Shutdown ( ) : void
return void

StartClient() public method

This starts a network client. It uses the networkAddress and networkPort properties as the address to connect to.

public StartClient ( ) : NetworkClient
return NetworkClient

StartClient() public method

public StartClient ( MatchInfo matchInfo ) : NetworkClient
matchInfo UnityEngine.Networking.Match.MatchInfo
return NetworkClient

StartClient() public method

public StartClient ( MatchInfo info, ConnectionConfig config ) : NetworkClient
info UnityEngine.Networking.Match.MatchInfo
config ConnectionConfig
return NetworkClient

StartHost() public method

This starts a network "host" - a server and client in the same application.

public StartHost ( ) : NetworkClient
return NetworkClient

StartHost() public method

public StartHost ( ConnectionConfig config, int maxConnections ) : NetworkClient
config ConnectionConfig
maxConnections int
return NetworkClient

StartHost() public method

public StartHost ( MatchInfo info ) : NetworkClient
info UnityEngine.Networking.Match.MatchInfo
return NetworkClient

StartMatchMaker() public method

This starts MatchMaker for the NetworkManager.

public StartMatchMaker ( ) : void
return void

StartServer() public method

This starts a new server.

public StartServer ( ) : bool
return bool

StartServer() public method

public StartServer ( ConnectionConfig config, int maxConnections ) : bool
config ConnectionConfig
maxConnections int
return bool

StartServer() public method

public StartServer ( MatchInfo info ) : bool
info UnityEngine.Networking.Match.MatchInfo
return bool

StopClient() public method

Stops the client that the manager is using.

public StopClient ( ) : void
return void

StopHost() public method

This stops both the client and the server that the manager is using.

public StopHost ( ) : void
return void

StopMatchMaker() public method

Stops the MatchMaker that the NetworkManager is using.

public StopMatchMaker ( ) : void
return void

StopServer() public method

Stops the server that the manager is using.

public StopServer ( ) : void
return void

UnRegisterStartPosition() public static method

Unregisters the transform of a game object as a player spawn location.

public static UnRegisterStartPosition ( Transform start ) : void
start UnityEngine.Transform
return void

UseExternalClient() public method

This allows the NetworkManager to use a client object created externally to the NetworkManager instead of using StartClient().

public UseExternalClient ( NetworkClient externalClient ) : void
externalClient NetworkClient The NetworkClient object to use.
return void

Property Details

client public_oe property

The current NetworkClient being used by the manager.

public NetworkClient,UnityEngine.Networking client
return NetworkClient

isNetworkActive public_oe property

True if the NetworkServer or NetworkClient isactive.

public bool isNetworkActive
return bool

matchInfo public_oe property

A MatchInfo instance that will be used when StartServer() or StartClient() are called.

public MatchInfo matchInfo
return MatchInfo

matchMaker public_oe property

The UMatch MatchMaker object.

public NetworkMatch matchMaker
return NetworkMatch

matches public_oe property

The list of matches that are available to join.

public List matches
return List

networkSceneName public_oe static_oe property

The name of the current network scene.

public static string networkSceneName
return string

singleton public_oe static_oe property

The NetworkManager singleton object.

public static NetworkManager singleton
return NetworkManager