[SOVLED] Photon GetRoomList Issues
Options
xXGriMe
✭
Im having a issue with this block of code.
Full Code
foreach (RoomInfo room in PhotonNetwork.GetRoomList()) { print (room.name); //Button temp = Instantiate (RoomButton) as Button; }Basically I just want this to print the rooms name "test" when a person connects to the lobby. I have 2 instances of the game running and on the first one i create the room and in the editor i play the game to look for the print statement but nothing happens. If i put that same block of code into void Update however it works but i dont want to do it every frame. Any idea why this works in update but not in OnJoinedLobby()? I tested the OnJoinedLobby() with a print statement and it works fine as long as the statement is outside of the while loop. I don't get any errors.
Full Code
using UnityEngine; using System.Collections; using UnityEngine.UI; public class LogicRoomSelect : MonoBehaviour { public Text AuthText; public Button RoomButton; private string GameVersion = "3rd Person V 0.01"; // Use this for initialization void Start () { PhotonNetwork.ConnectUsingSettings(GameVersion); } // Update is called once per frame void Update () { AuthText.text = (PhotonNetwork.connectionStateDetailed.ToString()); } public void CreateRoom() { PhotonNetwork.CreateRoom ("test", new RoomOptions() { maxPlayers = 8 }, null); Application.LoadLevel("3rd Person Game Test"); } public void MainMenu() { PhotonNetwork.Disconnect(); Application.LoadLevel("MainMenu"); } public void OnJoinedLobby() { foreach (RoomInfo room in PhotonNetwork.GetRoomList()) { print (room.name); //Button temp = Instantiate (RoomButton) as Button; } } }
0