Check If Room Exists

Options
When we creating a new Room using PhotonNetwork.CreateRoom and give It a name how to check If that Room name Exists or not ???

Comments

  • JANESTHEKING
    Options
    you can get list of room list available in lobby :
    RoomInfo[] rooms= PhotonNetwork.GetRoomList ();
  • Dev
    Options
    for(int i = 0; i < rooms.Count; i++)
    {
    if(newRoomBeingCreated.Equals(rooms[i].name))
    {
    Match!
    }
    }
  • CapPotato
    CapPotato
    edited April 2017
    Options
    RoomInfo[] rooms = PhotonNetwork.GetRoomList();

    for (int i = 0; i < rooms.Length; i++)
    {
    if (rooms[i].Name == "name")
    {
    Debug.Log("This room exists !");
    break;
    }
    }
  • CapPotato
    Options
    RoomInfo[] rooms = PhotonNetwork.GetRoomList();

    for (int i = 0; i < rooms.Length; i++)
    {
    if (rooms[i].Name == "name")
    {
    Debug.Log("This room exists !");
    break;
    }
    }
  • xblade724
    xblade724
    edited July 2017
    Options
    using System.Linq;
    
    List<RoomInfo> roomList = PhotonNetwork.GetRoomList().ToList();
    RoomInfo room  = roomList.FirstOrDefault(r => r.Name == roomName);
    bool exists = (room != null);
    
    :)