feat(HUD): Better HUD for WebGL (#3659)

* feat(HUD): Better HUD for WebGL

* restored comments

* fixed missing StopClient

* Simplified Stop Buttons
This commit is contained in:
MrGadget 2023-11-22 18:00:42 -05:00 committed by GitHub
parent d55967640f
commit f83d568e60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,10 +48,18 @@ void StartButtons()
{
if (!NetworkClient.active)
{
#if UNITY_WEBGL
// cant be a server in webgl build
if (GUILayout.Button("Single Player"))
{
NetworkServer.dontListen = true;
manager.StartHost();
}
#else
// Server + Client
if (Application.platform != RuntimePlatform.WebGLPlayer)
if (GUILayout.Button("Host (Server + Client)"))
manager.StartHost();
if (GUILayout.Button("Host (Server + Client)"))
manager.StartHost();
#endif
// Client + IP (+ PORT)
GUILayout.BeginHorizontal();
@ -75,13 +83,13 @@ void StartButtons()
GUILayout.EndHorizontal();
// Server Only
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
// cant be a server in webgl build
GUILayout.Box("( WebGL cannot be server )");
}
else
if (GUILayout.Button("Server Only")) manager.StartServer();
#if UNITY_WEBGL
// cant be a server in webgl build
GUILayout.Box("( WebGL cannot be server )");
#else
if (GUILayout.Button("Server Only"))
manager.StartServer();
#endif
}
else
{
@ -120,7 +128,10 @@ void StopButtons()
if (NetworkServer.active && NetworkClient.isConnected)
{
GUILayout.BeginHorizontal();
#if UNITY_WEBGL
if (GUILayout.Button("Stop Single Player"))
manager.StopHost();
#else
// stop host if host mode
if (GUILayout.Button("Stop Host"))
manager.StopHost();
@ -128,7 +139,7 @@ void StopButtons()
// stop client if host mode, leaving server up
if (GUILayout.Button("Stop Client"))
manager.StopClient();
#endif
GUILayout.EndHorizontal();
}
else if (NetworkClient.isConnected)