Browse Source

Add Lobby selection to menu

new_protocol
KeyKoder 5 years ago
parent
commit
7a34b33113
  1. 16
      unity/Assets/Scripts/MainMenuController.cs

16
unity/Assets/Scripts/MainMenuController.cs

@ -136,7 +136,7 @@ public class MainMenuController : MonoBehaviour {
if (conn != null) { if (conn != null) {
var lobby = conn.GetLobby(); var lobby = conn.GetLobby();
if (lobby != null) { if (lobby != null) {
//conn.LeaveLobby(); conn.LeaveLobby();
mainMenu.SetActive(false); mainMenu.SetActive(false);
serverMenu.SetActive(true); serverMenu.SetActive(true);
lobbyMenu.SetActive(false); lobbyMenu.SetActive(false);
@ -154,15 +154,17 @@ public class MainMenuController : MonoBehaviour {
var conn = Client.GetConnection(); var conn = Client.GetConnection();
if(conn != null) { if(conn != null) {
foreach(string lobby in conn.GetPublicLobbies()) { foreach(string lobby in conn.GetPublicLobbies()) {
Debug.Log(lobby); var lobbyGO = Instantiate(serverScroll.transform.GetChild(0), serverScroll.transform);
lobbyGO.GetComponentInChildren<Text>().text = lobby;
lobbyGO.gameObject.SetActive(true);
} }
// conn.Close(); // conn.Close();
} }
for (int i = 0; i < Random.Range(2, 15); i++) { //for (int i = 0; i < Random.Range(2, 15); i++) {
var lobby = Instantiate(serverScroll.transform.GetChild(0), serverScroll.transform); // var lobby = Instantiate(serverScroll.transform.GetChild(0), serverScroll.transform);
lobby.GetComponentInChildren<Text>().text = "LBY" + Random.Range(0, 10) + Random.Range(0, 10) + Random.Range(0, 10); // lobby.GetComponentInChildren<Text>().text = "LBY" + Random.Range(0, 10) + Random.Range(0, 10) + Random.Range(0, 10);
lobby.gameObject.SetActive(true); // lobby.gameObject.SetActive(true);
} //}
serverName.text = Client.GetConnection().Name(); serverName.text = Client.GetConnection().Name();
serverMenu.GetComponentInChildren<Scrollable>().Reload(); serverMenu.GetComponentInChildren<Scrollable>().Reload();
} }

Loading…
Cancel
Save