mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkDiscovery.OnGUI improved. Uses GUILayout now instead of manually spacing y.
This commit is contained in:
parent
565e5560f9
commit
daaa9f6d17
@ -357,47 +357,43 @@ void OnGUI()
|
||||
if (!m_ShowGUI)
|
||||
return;
|
||||
|
||||
int xpos = 10 + m_OffsetX;
|
||||
int ypos = 40 + m_OffsetY;
|
||||
const int spacing = 24;
|
||||
|
||||
if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
GUILayout.BeginArea(new Rect(10 + offsetX, 40 + offsetY, 215, 9999));
|
||||
if (Application.platform == RuntimePlatform.WebGLPlayer)
|
||||
{
|
||||
GUI.Box(new Rect(xpos, ypos, 200, 20), "( WebGL cannot broadcast )");
|
||||
return;
|
||||
GUILayout.Box("( WebGL cannot broadcast )");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (m_MsgInBuffer == null)
|
||||
{
|
||||
if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Initialize Broadcast"))
|
||||
if (GUILayout.Button("Initialize Broadcast"))
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
string suffix = "";
|
||||
if (m_IsServer)
|
||||
suffix = " (server)";
|
||||
if (m_IsClient)
|
||||
suffix = " (client)";
|
||||
|
||||
GUI.Label(new Rect(xpos, ypos, 200, 20), "initialized" + suffix);
|
||||
ypos += spacing;
|
||||
GUILayout.Label("initialized" + suffix);
|
||||
|
||||
if (m_Running)
|
||||
{
|
||||
if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Stop"))
|
||||
if (GUILayout.Button("Stop"))
|
||||
{
|
||||
StopBroadcast();
|
||||
}
|
||||
ypos += spacing;
|
||||
|
||||
if (m_BroadcastsReceived != null)
|
||||
{
|
||||
foreach (var addr in m_BroadcastsReceived.Keys)
|
||||
{
|
||||
var value = m_BroadcastsReceived[addr];
|
||||
if (GUI.Button(new Rect(xpos, ypos + 20, 200, 20), "Game at " + addr) && m_UseNetworkManager)
|
||||
if (GUILayout.Button("Game at " + addr) && m_UseNetworkManager)
|
||||
{
|
||||
string dataString = BytesToString(value.broadcastData);
|
||||
var items = dataString.Split(':');
|
||||
@ -411,25 +407,25 @@ void OnGUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
ypos += spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Start Broadcasting"))
|
||||
if (GUILayout.Button("Start Broadcasting"))
|
||||
{
|
||||
StartAsServer();
|
||||
}
|
||||
ypos += spacing;
|
||||
|
||||
if (GUI.Button(new Rect(xpos, ypos, 200, 20), "Listen for Broadcast"))
|
||||
if (GUILayout.Button("Listen for Broadcast"))
|
||||
{
|
||||
StartAsClient();
|
||||
}
|
||||
ypos += spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user