C# Класс UnityEngine.Networking.NetworkManager

Наследование: UnityEngine.MonoBehaviour
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
client NetworkClient
isNetworkActive bool
matchInfo MatchInfo
matchMaker NetworkMatch
matches List
networkSceneName string
singleton NetworkManager

Private Properties

Свойство Тип Описание
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

Открытые методы

Метод Описание
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().

Приватные методы

Метод Описание
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

Описание методов

GetStartPosition() публичный Метод

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

public GetStartPosition ( ) : Transform
Результат UnityEngine.Transform

IsClientConnected() публичный Метод

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

public IsClientConnected ( ) : bool
Результат bool

NetworkManager() публичный Метод

public NetworkManager ( ) : System
Результат System

OnClientConnect() публичный Метод

Called on the client when connected to a server.

public OnClientConnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection to the server.
Результат void

OnClientDisconnect() публичный Метод

Called on clients when disconnected from a server.

public OnClientDisconnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection to the server.
Результат void

OnClientError() публичный Метод

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.
Результат void

OnClientNotReady() публичный Метод

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.
Результат void

OnClientSceneChanged() публичный Метод

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.
Результат void

OnDestroyMatch() публичный Метод

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.
Результат void

OnDropConnection() публичный Метод

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.
Результат void

OnMatchCreate() публичный Метод

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.
Результат void

OnMatchJoined() публичный Метод

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.
Результат void

OnMatchList() публичный Метод

public OnMatchList ( bool success, string extendedInfo, List matchList ) : void
success bool
extendedInfo string
matchList List
Результат void

OnServerAddPlayer() публичный Метод

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.
Результат void

OnServerAddPlayer() публичный Метод

public OnServerAddPlayer ( NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader ) : void
conn NetworkConnection
playerControllerId short
extraMessageReader NetworkReader
Результат void

OnServerConnect() публичный Метод

Called on the server when a new client connects.

public OnServerConnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection from client.
Результат void

OnServerDisconnect() публичный Метод

Called on the server when a client disconnects.

public OnServerDisconnect ( NetworkConnection conn ) : void
conn NetworkConnection Connection from client.
Результат void

OnServerError() публичный Метод

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.
Результат void

OnServerReady() публичный Метод

Called on the server when a client is ready.

public OnServerReady ( NetworkConnection conn ) : void
conn NetworkConnection Connection from client.
Результат void

OnServerRemovePlayer() публичный Метод

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.
Результат void

OnServerSceneChanged() публичный Метод

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.
Результат void

OnSetMatchAttributes() публичный Метод

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.
Результат void

OnStartClient() публичный Метод

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.
Результат void

OnStartHost() публичный Метод

This hook is invoked when a host is started.

public OnStartHost ( ) : void
Результат void

OnStartServer() публичный Метод

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

public OnStartServer ( ) : void
Результат void

OnStopClient() публичный Метод

This hook is called when a client is stopped.

public OnStopClient ( ) : void
Результат void

OnStopHost() публичный Метод

This hook is called when a host is stopped.

public OnStopHost ( ) : void
Результат void

OnStopServer() публичный Метод

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

public OnStopServer ( ) : void
Результат void

RegisterStartPosition() публичный статический Метод

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

public static RegisterStartPosition ( Transform start ) : void
start UnityEngine.Transform Transform to register.
Результат void

ServerChangeScene() публичный Метод

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.
Результат void

SetMatchHost() публичный Метод

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.
Результат void

SetupMigrationManager() публичный Метод

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.
Результат void

Shutdown() публичный статический Метод

Shuts down the NetworkManager completely and destroy the singleton.

public static Shutdown ( ) : void
Результат void

StartClient() публичный Метод

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

public StartClient ( ) : NetworkClient
Результат NetworkClient

StartClient() публичный Метод

public StartClient ( MatchInfo matchInfo ) : NetworkClient
matchInfo UnityEngine.Networking.Match.MatchInfo
Результат NetworkClient

StartClient() публичный Метод

public StartClient ( MatchInfo info, ConnectionConfig config ) : NetworkClient
info UnityEngine.Networking.Match.MatchInfo
config ConnectionConfig
Результат NetworkClient

StartHost() публичный Метод

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

public StartHost ( ) : NetworkClient
Результат NetworkClient

StartHost() публичный Метод

public StartHost ( ConnectionConfig config, int maxConnections ) : NetworkClient
config ConnectionConfig
maxConnections int
Результат NetworkClient

StartHost() публичный Метод

public StartHost ( MatchInfo info ) : NetworkClient
info UnityEngine.Networking.Match.MatchInfo
Результат NetworkClient

StartMatchMaker() публичный Метод

This starts MatchMaker for the NetworkManager.

public StartMatchMaker ( ) : void
Результат void

StartServer() публичный Метод

This starts a new server.

public StartServer ( ) : bool
Результат bool

StartServer() публичный Метод

public StartServer ( ConnectionConfig config, int maxConnections ) : bool
config ConnectionConfig
maxConnections int
Результат bool

StartServer() публичный Метод

public StartServer ( MatchInfo info ) : bool
info UnityEngine.Networking.Match.MatchInfo
Результат bool

StopClient() публичный Метод

Stops the client that the manager is using.

public StopClient ( ) : void
Результат void

StopHost() публичный Метод

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

public StopHost ( ) : void
Результат void

StopMatchMaker() публичный Метод

Stops the MatchMaker that the NetworkManager is using.

public StopMatchMaker ( ) : void
Результат void

StopServer() публичный Метод

Stops the server that the manager is using.

public StopServer ( ) : void
Результат void

UnRegisterStartPosition() публичный статический Метод

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

public static UnRegisterStartPosition ( Transform start ) : void
start UnityEngine.Transform
Результат void

UseExternalClient() публичный Метод

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.
Результат void

Описание свойств

client публичное свойство

The current NetworkClient being used by the manager.

public NetworkClient,UnityEngine.Networking client
Результат NetworkClient

isNetworkActive публичное свойство

True if the NetworkServer or NetworkClient isactive.

public bool isNetworkActive
Результат bool

matchInfo публичное свойство

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

public MatchInfo matchInfo
Результат MatchInfo

matchMaker публичное свойство

The UMatch MatchMaker object.

public NetworkMatch matchMaker
Результат NetworkMatch

matches публичное свойство

The list of matches that are available to join.

public List matches
Результат List

networkSceneName публичное статическое свойство

The name of the current network scene.

public static string networkSceneName
Результат string

singleton публичное статическое свойство

The NetworkManager singleton object.

public static NetworkManager singleton
Результат NetworkManager