private void ConnectToServer() { ICEventfulNetworkDiscovery networkDiscovery = GetNetworkDiscovery(); if (networkDiscovery.servers.ContainsKey(serverList.selectedItem)) { var server = networkDiscovery.servers[serverList.selectedItem]; var parts = server.Data.Split(':'); var address = parts[1]; int port; int.TryParse(parts[2], out port); experimentSetup.StartClient(address, port); } }
/** * Returns an instance of the ICEventfulNetworkDiscovery. */ public static ICEventfulNetworkDiscovery GetNetworkDiscovery() { GameObject networkManagerObject = GameObject.Find("NetworkManager"); if (!networkManagerObject) { networkManagerObject = new GameObject(); } ICEventfulNetworkDiscovery networkDiscovery = networkManagerObject.GetComponent <ICEventfulNetworkDiscovery>(); if (!networkDiscovery) { networkDiscovery = networkManagerObject.AddComponent <ICEventfulNetworkDiscovery>(); networkDiscovery.useNetworkManager = false; } return(networkDiscovery); }