mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
feat: adding script to help debug list server (#2202)
Script uses OnGui so can be used to check if server has been added to list server
This commit is contained in:
parent
fc530782cc
commit
5701369e84
@ -0,0 +1,46 @@
|
||||
using Mirror.Cloud.ListServerService;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Cloud.Example
|
||||
{
|
||||
/// <summary>
|
||||
/// This Script can be used to test the list server without needing to use canvas or other UI
|
||||
/// </summary>
|
||||
public class QuickListServerDebug : MonoBehaviour
|
||||
{
|
||||
ApiConnector connector;
|
||||
ServerCollectionJson? collection;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
NetworkManager manager = NetworkManager.singleton;
|
||||
connector = manager.GetComponent<ApiConnector>();
|
||||
|
||||
connector.ListServer.ClientApi.onServerListUpdated += ClientApi_onServerListUpdated;
|
||||
}
|
||||
|
||||
private void ClientApi_onServerListUpdated(ServerCollectionJson arg0)
|
||||
{
|
||||
collection = arg0;
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
GUILayout.Label("List Server");
|
||||
if (GUILayout.Button("Refresh"))
|
||||
{
|
||||
connector.ListServer.ClientApi.GetServerList();
|
||||
}
|
||||
GUILayout.Space(40);
|
||||
|
||||
if (collection != null)
|
||||
{
|
||||
GUILayout.Label("Servers:");
|
||||
foreach (ServerJson item in collection.Value.servers)
|
||||
{
|
||||
GUILayout.Label($"{item.displayName}, {item.address}, {item.playerCount}/{item.maxPlayerCount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07d1ea5260bc06e4d831c4b61d494bff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user