Quantcast
Channel: Recent Discussions — Photon Engine
Viewing all articles
Browse latest Browse all 15755

Getting RoomInfo.customProperties in Lobby

$
0
0
Hi I'm trying to figure out why in the lobby I'm having trouble grabbing the customProperties of the rooms that are created.

On the room's creation, it sets the hashtable value "levelName" to Application.loadedLevelName. And when other players join the room, they can see the variable just fine through PhotonNetwork.room.customProperties["levelName"].ToString()

I set it like this and it reads just fine when another player joins the room.
if(PhotonNetwork.isMasterClient)
       {
        h = new Hashtable();
        h.Add("levelName", Application.loadedLevelName);
      
        PhotonNetwork.room.SetCustomProperties(h);
       }

But in the lobby when I ask for the RoomInfo.customProperties is says it's length is 0 and "levelName" doesn't exist.
foreach (RoomInfo roomInfo in PhotonNetwork.GetRoomList())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(roomInfo.name + " " + roomInfo.playerCount + "/" + roomInfo.maxPlayers +" / "+roomInfo.customProperties.Count);
                
                if (roomInfo.customProperties.ContainsKey("levelName"))
                {
                Debug.Log("found levelName");
                GUILayout.Label(roomInfo.customProperties["levelName"].ToString());//.ToString());
                }
                
                if (GUILayout.Button("JOIN"))
                {
                    PhotonNetwork.JoinRoom(roomInfo.name);
                }
}

I'm not sure if I'm trying to get this data the wrong way or if I'm setting it the wrong way.

Viewing all articles
Browse latest Browse all 15755

Trending Articles