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:
James Frowen 2020-08-27 23:15:43 +01:00 committed by GitHub
parent fc530782cc
commit 5701369e84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions

View File

@ -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}");
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 07d1ea5260bc06e4d831c4b61d494bff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: