8 [DisallowMultipleComponent]
9 [AddComponentMenu(
"Network/Network Manager HUD")]
10 [RequireComponent(typeof(NetworkManager))]
11 [HelpURL(
"https://mirror-networking.gitbook.io/docs/components/network-manager-hud")]
21 manager = GetComponent<NetworkManager>();
26 GUILayout.BeginArea(
new Rect(10 + offsetX, 40 + offsetY, 215, 9999));
39 if (GUILayout.Button(
"Client Ready"))
59 if (Application.platform != RuntimePlatform.WebGLPlayer)
61 if (GUILayout.Button(
"Host (Server + Client)"))
68 GUILayout.BeginHorizontal();
69 if (GUILayout.Button(
"Client"))
74 manager.networkAddress = GUILayout.TextField(manager.
networkAddress);
75 GUILayout.EndHorizontal();
78 if (Application.platform == RuntimePlatform.WebGLPlayer)
81 GUILayout.Box(
"( WebGL cannot be server )");
85 if (GUILayout.Button(
"Server Only")) manager.
StartServer();
91 GUILayout.Label($
"Connecting to {manager.networkAddress}..");
92 if (GUILayout.Button(
"Cancel Connection Attempt"))
107 GUILayout.Label($
"<b>Host</b>: running via {Transport.activeTransport}");
112 GUILayout.Label($
"<b>Server</b>: running via {Transport.activeTransport}");
117 GUILayout.Label($
"<b>Client</b>: connected to {manager.networkAddress} via {Transport.activeTransport}");
126 if (GUILayout.Button(
"Stop Host"))
134 if (GUILayout.Button(
"Stop Client"))
142 if (GUILayout.Button(
"Stop Server"))
NetworkClient with connection to server.
static bool active
active is true while a client is connecting/connected
static bool ready
True if client is ready (= joined world).
static bool Ready()
Sends Ready message to server, indicating that we loaded the scene, ready to enter the game.
static bool AddPlayer()
Sends AddPlayer message to the server, indicating that we want to join the world.
static bool isConnected
Check if client is connected (after connecting).
static NetworkIdentity localPlayer
NetworkIdentity of the localPlayer
Shows NetworkManager controls in a GUI at runtime.
void StartClient()
Starts the client, connects it to the server with networkAddress.
void StopHost()
This stops both the client and the server that the manager is using.
void StopServer()
Stops the server from listening and simulating the game.
void StartHost()
Starts a network "host" - a server and client in the same application.
string networkAddress
Server's address for clients to connect to.
void StopClient()
Stops and disconnects the client.
void StartServer()
Starts the server, listening for incoming connections.
NetworkServer handles remote connections and has a local connection for a local client.
static bool active
active checks if the server has been started