- Home /
Photon Networking create room issue
When i try and create a room, it doesn't create and i have absolutely no cue why, i've tried debugging and i can't find the issue. Here is my code:
using UnityEngine;
using System.Collections;
public class StartRoom : MonoBehaviour {
public UnityEngine.UI.InputField input;
public string RoomName="";
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
RoomName=input.value;
if(Input.GetKeyDown(KeyCode.Return))
{
RoomName=input.value;
StartRoomByName();
}
//Debug.Log(PhotonNetwork.GetRoomList().Length);
}
void StartRoomByName()
{
PhotonNetwork.ConnectUsingSettings ("1.0");
}
void OnGUI()
{
GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
}
void OnJoinedLobby()
{
PhotonNetwork.CreateRoom (RoomName);
}
void OnCreatedRoom()
{
PhotonNetwork.JoinRoom (RoomName);
}
}
And here is the error i keep getting:
JoinRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
UnityEngine.Debug:LogError(Object)
PhotonNetwork:JoinRoom(String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1575)
StartRoom:OnCreatedRoom() (at Assets/StartRoom.cs:42)
When you attempt to run the scene. What state does your ongui label show it getting stuck at?
Answer by Truger · Feb 08, 2015 at 04:51 PM
As Soon as the the scene starts running the photon plugin will automatically connect to the master server only the lobby will update list as soon you create a room and join the list will not update anymore so it wont show the new you room you just created
As documented here link text
I copy/pasted the example from the link to show rooms, this works "while in a lobby". It wont work if you have created a room. at least i don't know of or believe it does
foreach (RoomInfo game in PhotonNetwork.GetRoomList())
{
GUILayout.Label(game.name + " " + game.playerCount + "/" + game.maxPlayers);
}
Hope this helps.
Your answer
Follow this Question
Related Questions
Unity photon network - game room 1 Answer
Join room and create if not existing. 0 Answers
Photon unity issues 2 Answers
Photon Network Cant Destroy Game Object In All Clients 3 Answers
How to get all created rooms and join any one of them in PHOTON 2 Answers