void Start() { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); // wait 2 + random seconds before trying to connect so we find any servers out there already Invoke("tryConnect", 2 + (int)UnityEngine.Random.Range(0, 4)); }
void DrawGUI() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Find Servers")) { discoveredServers.Clear(); //clear existing servers networkDiscovery.StartDiscovery(); //search for more servers Debug.Log("NetworkDiscoveryHUD: Searching for servers..."); Debug.Log("NetworkDiscoveryHUD: Discovered Servers: " + discoveredServers.Count); } // LAN Host if (GUILayout.Button("Start Host")) { discoveredServers.Clear(); //clear existing servers NetworkManager.singleton.StartHost(); //start a new network manager host networkDiscovery.AdvertiseServer(); //advertises this new host in the list } // Dedicated server if (GUILayout.Button("Start Server")) { discoveredServers.Clear(); NetworkManager.singleton.StartServer(); networkDiscovery.AdvertiseServer(); } GUILayout.EndHorizontal(); // show list of found server GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:"); // servers scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); Debug.Log("Discovered Servers: " + discoveredServers.Count.ToString()); foreach (ServerResponse info in discoveredServers.Values) { Debug.Log("Found this server: " + info.EndPoint.Address.ToString()); if (GUILayout.Button(info.EndPoint.Address.ToString())) { Connect(info); //Connect and start the client according to the server that sent it } Debug.Log("Connecting to: " + info.EndPoint.Address.ToString()); } GUILayout.EndScrollView(); }
void DrawGUI() { GUILayout.BeginHorizontal(); mainStyle.fontSize = 24; mainStyle.fixedHeight = 500; mainStyle.fixedWidth = 500; if ((GUILayout.Button("Find Servers", GUILayout.Width(200), GUILayout.Height(100)))) { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); } // LAN Host if (GUILayout.Button("Start Host", GUILayout.Width(200), GUILayout.Height(100))) { discoveredServers.Clear(); NetworkManager.singleton.StartHost(); networkDiscovery.AdvertiseServer(); } // Dedicated server /*if (GUILayout.Button("Start Server")) * { * discoveredServers.Clear(); * NetworkManager.singleton.StartServer(); * * networkDiscovery.AdvertiseServer(); * }*/ GUILayout.EndHorizontal(); // show list of found server GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:", GUILayout.Width(200), GUILayout.Height(100)); // servers scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); foreach (ServerResponse info in discoveredServers.Values) { if (GUILayout.Button(info.EndPoint.Address.ToString())) { Connect(info); } } GUILayout.EndScrollView(); }
void DrawGUI() { //GUILayout.BeginHorizontal(); GUILayout.BeginArea(new Rect(10 + Screen.width / 2, 40 + Screen.height / 2, 215, 9999)); if (GUILayout.Button("Find Servers")) { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); } // LAN Host if (GUILayout.Button("Start Host")) { discoveredServers.Clear(); NetworkManager.singleton.StartHost(); networkDiscovery.AdvertiseServer(); } // Dedicated server if (GUILayout.Button("Start Server")) { discoveredServers.Clear(); NetworkManager.singleton.StartServer(); networkDiscovery.AdvertiseServer(); } // GUILayout.EndHorizontal(); GUILayout.EndArea(); // show list of found server GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:"); // servers scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); foreach (ServerResponse info in discoveredServers.Values) { if (GUILayout.Button(info.EndPoint.Address.ToString())) { Connect(info); } } GUILayout.EndScrollView(); }
void DrawGUI() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Find Servers")) { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); } // LANCER CA QUAND BOUTON JOIN APPUYE // LAN Host if (GUILayout.Button("Start Host")) { discoveredServers.Clear(); NetworkManager.singleton.StartHost(); networkDiscovery.AdvertiseServer(); } // LANCER QUAND BOUTON HOST APPUYE // Dedicated server if (GUILayout.Button("Start Server")) { discoveredServers.Clear(); NetworkManager.singleton.StartServer(); networkDiscovery.AdvertiseServer(); } // USELESS FOR US GUILayout.EndHorizontal(); // show list of found server GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:"); // servers scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); Debug.Log(discoveredServers.Count); foreach (ServerResponse info in discoveredServers.Values) { if (GUILayout.Button(info.EndPoint.Address.ToString())) { Connect(info); // LIST OF ALL SERVERS DISCOVERED } } GUILayout.EndScrollView(); }
void DrawGUI() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Find Servers")) { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); } // LAN Host if (GUILayout.Button("Start Host")) { discoveredServers.Clear(); networkManager.server.StartHost(networkManager.client).Forget(); networkDiscovery.AdvertiseServer(); } // Dedicated server if (GUILayout.Button("Start Server")) { discoveredServers.Clear(); networkManager.server.ListenAsync().Forget(); networkDiscovery.AdvertiseServer(); } GUILayout.EndHorizontal(); // show list of found server GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:"); // servers scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); foreach (ServerResponse info in discoveredServers.Values) { if (GUILayout.Button(info.EndPoint.Address.ToString())) { Connect(info); } } GUILayout.EndScrollView(); }
private void DrawGUI() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Find Servers")) { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); } // LAN Host if (GUILayout.Button("Start Host")) { discoveredServers.Clear(); NetworkManager.singleton.StartHost(); networkDiscovery.AdvertiseServer(); } // Dedicated server if (GUILayout.Button("Start Server")) { discoveredServers.Clear(); NetworkManager.singleton.StartServer(); networkDiscovery.AdvertiseServer(); } GUILayout.EndHorizontal(); // show list of found server GUILayout.Label($"Discovered Servers [{discoveredServers.Count}]:"); // servers scrollViewPos = GUILayout.BeginScrollView(scrollViewPos); foreach (var info in discoveredServers.Values) if (GUILayout.Button(info.EndPoint.Address.ToString())) Connect(info); GUILayout.EndScrollView(); }
public void FindServers() { discoveredServers.Clear(); networkDiscovery.StartDiscovery(); }