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) {
var lobby = conn.GetLobby();
if (lobby != null) {
//conn.LeaveLobby();
conn.LeaveLobby();
mainMenu.SetActive(false);
serverMenu.SetActive(true);
lobbyMenu.SetActive(false);
@ -154,15 +154,17 @@ public class MainMenuController : MonoBehaviour {
var conn = Client.GetConnection();
if(conn != null) {
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();
}
for (int i = 0; i < Random.Range(2, 15); i++) {
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.gameObject.SetActive(true);
}
//for (int i = 0; i < Random.Range(2, 15); i++) {
// 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.gameObject.SetActive(true);
//}
serverName.text = Client.GetConnection().Name();
serverMenu.GetComponentInChildren<Scrollable>().Reload();
}

Loading…
Cancel
Save