Server discovery

Here is a sample script showing how you can use the server discovery API to get the servers associated with your runtime key.

// Initialize network API
Network.Init(RuntimeSettings.instance.playToken);

// Get the list of servers associated with the token
var network = World.DefaultGameObjectInjectionWorld.GetExistingSystem<NetworkSystem>();
if (network.ConnectionAddresses != null)
{
    foreach (var connection in network.ConnectionAddresses)
    {
        serverDropdown.options.Add(new Dropdown.OptionData
        {
            text = string.Format("{0} {1}:{2}", connection.region, connection.ip, connection.port)
        });
    }
    serverDropdown.value = serverDropdown.options.Count - 1;
}

Last updated